14 from optparse
import OptionParser
17 jobHash =
"%s_%s_%s" % (os.getuid(), os.getpid(), int(time.time()))
19 usage =
'%prog [options]. \n\t-a and -k required, -h for help.'
20 parser = OptionParser(usage)
21 parser.add_option(
"-a",
"--analysis", dest=
"analysis",
22 help=
"analysis configuration file")
26 parser.add_option(
"-k",
"--hltkey", dest=
"hltkey",
27 help=
"ignore RunRegistry and force the use of HLT key KEY",
29 parser.add_option(
"-c",
"--hltcff", dest=
"hltcff",
30 help=
"use the config fragment CFF to define HLT configuration",
32 parser.add_option(
"-f",
"--frontier", dest=
"frontier",
33 help=
"frontier connection string to use, defaults to frontier://FrontierProd/CMS_COND_21X_GLOBALTAG",
34 default=
"frontier://FrontierProd/CMS_COND_31X_GLOBALTAG")
37 (options, args) = parser.parse_args()
39 if options.hltkey ==
None and options.hltcff ==
None:
40 parser.error(
"I don't have all the required options.")
42 "Please specify one of --hltkey (-k) or --hltcff (-s)")
43 if options.hltkey !=
None and options.hltcff !=
None:
44 raise SystemExit(
"Please only specify --hltkey (-k) or --hltcff (-c)")
49 if options.analysis ==
None:
51 "Please specify an analysis configuration: -a or --analysis")
58 raise SystemExit(
"Must run from a Module/Package/python directory")
63 onlineFrontier = re.search(
'"(frontier:.*)"', config)
64 if not onlineFrontier:
65 print "WARNING: Could not find Frontier string in HLT configuration. Will ignore."
67 config = config.replace(onlineFrontier.group(1), frontierString)
70 config = config.replace(
"H::All",
"P::All")
77 config =
RemovePSet(config,
"FUShmDQMOutputService")
82 startLoc = config.find(pset)
90 if config[curLoc] ==
"(":
97 if config[curLoc] ==
"(":
99 elif config[curLoc] ==
")":
105 config = config.replace(config[startLoc:endLoc + 1],
"")
118 config = os.popen2(
'wget "http://cms-project-confdb-hltdev.web.cern.ch/cms-project-confdb-hltdev/get.jsp?dbName=ORCOFF&configName=%s&cff=&nooutput=&format=Python" -O- -o /dev/null' % hltKey)[1].
read()
120 configName =
"JobHLTConfig_%s_cff.py" % jobHash
126 f = open(configName,
"w")
130 return 'process.load("%s.%s.%s")' % (module, package, configName.split(
".")[0])
134 raise SystemExit(
"Not implemented yet")
138 pathParts = cffPath.split(
".")
139 if not re.match(
"^[_A-Za-z0-9]*\.[_A-Za-z0-9]*\.[_A-Za-z0-9]*$", cffPath):
140 raise SystemExit(
"Expected cff in form Package.Module.configName_cff")
141 return 'process.load("%s")' % cffPath
145 tmpCode = compileCode.replace(
"SUBSYSTEM", subsystem)
146 tmpCode = tmpCode.replace(
"PACKAGE", package)
147 tmpCode = tmpCode.replace(
"CONFIG", hltConfig +
"c")
152 anaName =
"JobAnalysisConfig_%s_cfg.py" % jobHash
154 g = open(anaName,
"w")
167 if options.hltkey !=
None:
169 elif options.hltcff !=
None:
179 print "Using HLT configuration: %s" % hltConfig
181 print "Created HLT configuration: %s" % hltConfig
182 print "Created analysis configuration: %s" % anaConfig
def ConvertHltOnlineToOffline