Go to the documentation of this file.00001
00002
00003 from FWCore.PythonUtilities.XML2Python import xml2obj
00004 from FWCore.PythonUtilities.LumiList import LumiList
00005 from pprint import pprint
00006 import optparse
00007 import sys
00008
00009
00010 if __name__ == '__main__':
00011
00012 parser = optparse.OptionParser ("Usage: %prog [--options] job1.fjr [job2.fjr...]")
00013 parser.add_option ('--output', dest='output', type='string',
00014 help='Save output to file OUTPUT')
00015 (options, args) = parser.parse_args()
00016 if not args:
00017 raise RuntimeError, "Must provide at least one input file"
00018
00019 runsLumisDict = {}
00020 for fjr in args:
00021 try:
00022 obj = xml2obj (filename=fjr)
00023 except:
00024 print "'%s' is not an framework job report. Skipping." % fjr
00025 continue
00026 for inputFile in obj.InputFile:
00027 try:
00028 runList = inputFile.Runs.Run
00029 except:
00030 try:
00031 print "'%s' in '%s' contains no runs. Skipping." % \
00032 (inputFile.PFN, fjr)
00033 except:
00034 print "Some run in '%s' contains no runs. Skipping." % \
00035 fjr
00036 continue
00037 for run in runList:
00038 runNumber = int (run.ID)
00039 runList = runsLumisDict.setdefault (runNumber, [])
00040 for lumiPiece in run.LumiSection:
00041 lumi = int (lumiPiece.ID)
00042 runList.append (lumi)
00043
00044 jsonList = LumiList (runsAndLumis = runsLumisDict)
00045 if options.output:
00046 jsonList.writeJSON (options.output)
00047 else:
00048 print jsonList
00049