2 from sys
import stderr, exit
12 from optparse
import OptionParser
13 parser = OptionParser(usage=
"usage: %prog [options] ")
14 parser.add_option(
"--firstRun", dest=
"firstRun", help=
"first run", type=
"int", metavar=
"RUN", default=
"1")
15 parser.add_option(
"--lastRun", dest=
"lastRun", help=
"last run", type=
"int", metavar=
"RUN", default=
"9999999")
16 parser.add_option(
"--groupName", dest=
"groupName", help=
"select runs of name like NAME", metavar=
"NAME", default=
"Collisions%")
17 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")
18 parser.add_option(
"--HLTkey", dest=
"HLTkey", help=
"name of the HLTkey e.g. /cdaq/physics/Run2010/v3.1/HLT_1.6E30/V1",metavar=
"HLT")
19 parser.add_option(
"--perKey", action=
"store_true",default=
False,dest=
"perKey",help=
"list the runs per HLT key",metavar=
"perKey")
20 (options, args) = parser.parse_args()
23 stderr.write(
"Querying run registry for range [%d, %d], group name like %s ...\n" % (options.firstRun, options.lastRun, options.groupName))
26 server = xmlrpclib.ServerProxy(options.rrurl)
27 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))
29 xml_data = xml.dom.minidom.parseString(run_data)
30 xml_runs = xml_data.documentElement.getElementsByTagName(
"RUN_DATASET")
31 for xml_run
in xml_runs:
32 ret[xml_run.getElementsByTagName(
"RUN_NUMBER")[0].firstChild.nodeValue] = xml_run.getElementsByTagName(
"RUN_HLTKEY")[0].firstChild.nodeValue
36 runs = runKeys.keys(); runs.sort()
42 if not key
in runsPerKey.keys():
45 runsPerKey[key] = tmpruns
47 runsPerKey[key].
append(run)
48 theKeys = runsPerKey.keys()
50 theruns = runsPerKey[key]
58 HLTkey = options.HLTkey
59 print "List of runs taken with HLT key = ",HLTkey
63 if not options.HLTkey:
66 if key == options.HLTkey: