2 from sys
import stderr, exit
5 from optparse
import OptionParser
6 parser = OptionParser(usage=
"usage: %prog [options] Trigger_Path")
7 parser.add_option(
"--firstRun", dest=
"firstRun", help=
"first run", type=
"int", metavar=
"RUN", default=
"1")
8 parser.add_option(
"--lastRun", dest=
"lastRun", help=
"last run", type=
"int", metavar=
"RUN", default=
"9999999")
9 parser.add_option(
"--groupName", dest=
"groupName", help=
"select runs of name like NAME", metavar=
"NAME", default=
"Collisions%")
10 parser.add_option(
"--rrurl", dest=
"rrurl", help=
"run registry xmlrpc url", metavar=
"URL", default=
"http://cms-service-runregistry-api.web.cern.ch/cms-service-runregistry-api/xmlrpc")
11 parser.add_option(
"--jsonOut", dest=
"jsonOut", help=
"dump prescales in JSON format on FILE", metavar=
"FILE")
12 (options, args) = parser.parse_args()
19 edmCfgFromDB =
"edmConfigFromDB --orcoff --format summary.ascii --paths " + path;
23 cmd = ( edmCfgFromDB +
" --configName "+key +
" | grep -i "+ path +
" | tail -1 | awk ' $2 ==\"%s\" {print $NL}' " ) % path
24 res = commands.getoutput(cmd)
25 res_split = res.split()
29 for uu
in range(3,len(res_split)-1):
31 aa = aa + res_split[uu] +
"\t"
39 stderr.write(
"Querying run registry for range [%d, %d], group name like %s ...\n" % (options.firstRun, options.lastRun, options.groupName))
42 server = xmlrpclib.ServerProxy(options.rrurl)
43 run_data = server.DataExporter.export(
'RUN',
'GLOBAL',
'xml_datasets',
"{runNumber} >= %d AND {runNumber} <= %d AND {groupName} like '%s' AND {datasetName} = '/Global/Online/ALL'" % (options.firstRun, options.lastRun, options.groupName))
45 xml_data = xml.dom.minidom.parseString(run_data)
46 xml_runs = xml_data.documentElement.getElementsByTagName(
"RUN_DATASET")
47 for xml_run
in xml_runs:
48 ret[xml_run.getElementsByTagName(
"RUN_NUMBER")[0].firstChild.nodeValue] = xml_run.getElementsByTagName(
"RUN_HLTKEY")[0].firstChild.nodeValue
53 runs = runKeys.keys(); runs.sort()
54 stderr.write(
"Querying ConfDB for prescales for path %s...\n" % (path));
58 if not prescaleTable.has_key(key):
61 if prescaleTable[key].has_key(path): psfactor = prescaleTable[key][path]
62 print "%s\t%s" % (run, psfactor)
66 stderr.write(
"Exporting to JSON file %s...\n" % (options.jsonOut))
68 jsonFile = open(options.jsonOut,
"w")
69 jsonFile.write(json.dumps(jsout))
def getPrescalesFromKey
my $pyPrintTable = "echo 'for X in process.PrescaleService.prescaleTable: print \"%s %s" % (X...