Go to the documentation of this file.00001
00002 from sys import stderr, exit
00003 import commands
00004
00005
00006
00007
00008
00009
00010
00011
00012 from optparse import OptionParser
00013 parser = OptionParser(usage="usage: %prog [options] ")
00014 parser.add_option("--firstRun", dest="firstRun", help="first run", type="int", metavar="RUN", default="1")
00015 parser.add_option("--lastRun", dest="lastRun", help="last run", type="int", metavar="RUN", default="9999999")
00016 parser.add_option("--groupName", dest="groupName", help="select runs of name like NAME", metavar="NAME", default="Collisions%")
00017 parser.add_option("--rrurl", dest="rrurl", help="run registry xmlrpc url", metavar="URL", default="https://cms-service-runregistry-api.web.cern.ch/cms-service-runregistry-api/xmlrpc")
00018 parser.add_option("--HLTkey", dest="HLTkey", help="name of the HLTkey e.g. /cdaq/physics/Run2010/v3.1/HLT_1.6E30/V1",metavar="HLT")
00019 parser.add_option("--perKey", action="store_true",default=False,dest="perKey",help="list the runs per HLT key",metavar="perKey")
00020 (options, args) = parser.parse_args()
00021
00022 def queryRR():
00023 stderr.write("Querying run registry for range [%d, %d], group name like %s ...\n" % (options.firstRun, options.lastRun, options.groupName))
00024 import xmlrpclib
00025 import xml.dom.minidom
00026 server = xmlrpclib.ServerProxy(options.rrurl)
00027 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))
00028 ret = {}
00029 xml_data = xml.dom.minidom.parseString(run_data)
00030 xml_runs = xml_data.documentElement.getElementsByTagName("RUN_DATASET")
00031 for xml_run in xml_runs:
00032 ret[xml_run.getElementsByTagName("RUN_NUMBER")[0].firstChild.nodeValue] = xml_run.getElementsByTagName("RUN_HLTKEY")[0].firstChild.nodeValue
00033 return ret
00034
00035 runKeys = queryRR()
00036 runs = runKeys.keys(); runs.sort()
00037
00038 if options.perKey:
00039 runsPerKey={}
00040 for run in runs:
00041 key = runKeys[run]
00042 if not key in runsPerKey.keys():
00043 tmpruns=[]
00044 tmpruns.append(run)
00045 runsPerKey[key] = tmpruns
00046 else:
00047 runsPerKey[key].append(run)
00048 theKeys = runsPerKey.keys()
00049 for key in theKeys:
00050 theruns = runsPerKey[key]
00051 topr=""
00052 for r in theruns:
00053 topr=topr+"\t"+r
00054 print key,topr
00055 exit(1)
00056
00057 if options.HLTkey:
00058 HLTkey = options.HLTkey
00059 print "List of runs taken with HLT key = ",HLTkey
00060 for run in runs:
00061 key = runKeys[run]
00062
00063 if not options.HLTkey:
00064 print run,key
00065 else:
00066 if key == options.HLTkey:
00067 print run