11 from collections
import Counter
33 databases[
'v1'][
'offline'] = (
'-t',
'oracle',
'-h',
'cmsr1-s.cern.ch',
'-d',
'cms_cond.cern.ch',
'-u',
'cms_hltdev_reader',
'-s',
'convertMe!' )
34 databases[
'v1'][
'hltdev'] = databases[
'v1'][
'offline']
35 databases[
'v1'][
'online'] = (
'-t',
'oracle',
'-h',
'cmsonr1-s.cms',
'-d',
'cms_rcms.cern.ch',
'-u',
'cms_hlt_r',
'-s',
'convertMe!' )
36 databases[
'v1'][
'adg'] = (
'-t',
'oracle',
'-h',
'cmsr1-s.cern.ch',
'-d',
'cms_cond.cern.ch',
'-u',
'cms_hlt_gui_r',
'-s',
'convertMe!' )
37 databases[
'v1'][
'orcoff'] = databases[
'v1'][
'adg']
39 databases[
'v3'][
'run2'] = (
'-t',
'oracle',
'-h',
'cmsr1-s.cern.ch,cmsr2-s.cern.ch,cmsr3-s.cern.ch',
'-d',
'cms_hlt.cern.ch',
'-u',
'cms_hlt_gdr_r',
'-s',
'convertMe!' )
40 databases[
'v3'][
'run3'] = (
'-t',
'oracle',
'-h',
'cmsr1-s.cern.ch,cmsr2-s.cern.ch,cmsr3-s.cern.ch',
'-d',
'cms_hlt.cern.ch',
'-u',
'cms_hlt_v3_r',
'-s',
'convertMe!' )
41 databases[
'v3'][
'dev'] = (
'-t',
'oracle',
'-h',
'cmsr1-s.cern.ch,cmsr2-s.cern.ch,cmsr3-s.cern.ch',
'-d',
'cms_hlt.cern.ch',
'-u',
'cms_hlt_gdrdev_r',
'-s',
'convertMe1!' )
42 databases[
'v3'][
'online'] = (
'-t',
'oracle',
'-h',
'cmsonr1-s.cms',
'-d',
'cms_rcms.cern.ch',
'-u',
'cms_hlt_gdr_r',
'-s',
'convertMe!' )
43 databases[
'v3'][
'adg'] = (
'-t',
'oracle',
'-h',
'cmsonr1-adg1-s.cern.ch',
'-d',
'cms_orcon_adg.cern.ch',
'-u',
'cms_hlt_gdr_r',
'-s',
'convertMe!' )
47 'cmsr1-s.cern.ch' :
'10.116.96.89',
48 'cmsr2-s.cern.ch' :
'10.116.96.139',
49 'cmsr3-s.cern.ch' :
'10.116.96.105'
52 databases[
'v3-beta'] = dict(databases[
'v3'])
53 databases[
'v3-test'] = dict(databases[
'v3'])
54 databases[
'v2'] = dict(databases[
'v3'])
56 for dbkey
in databases[
'v2']:
57 dbparams = databases[
'v2'][dbkey]
58 if dbparams[3]==
'cmsr1-s.cern.ch,cmsr2-s.cern.ch,cmsr3-s.cern.ch':
59 databases[
'v2'][dbkey] = dbparams[0:3]+(
'cmsr1-s.cern.ch',)+dbparams[4:]
63 dir = os.path.realpath(dir)
64 if not os.path.isdir(dir):
72 def __init__(self, version = 'v3', database = 'run3', url = None, verbose = False,
73 proxy =
False, proxyHost =
'localhost', proxyPort =
'8080'):
76 self.
baseDir =
'/afs/cern.ch/user/c/confdb/www/%s/lib' % version
77 self.
baseUrl =
'https://confdb.web.cern.ch/confdb/%s/lib' % version
78 self.
jars = (
'ojdbc8.jar',
'cmssw-evf-confdb-converter.jar' )
81 self.
jars = (
'ojdbc6.jar',
'cmssw-evf-confdb-converter.jar' )
90 sys.stderr.write(
"ERROR: unsupported database version \"%s\"\n" % version)
98 sys.stderr.write(
"ERROR: unknown database \"%s\" for version \"%s\"\n" % (database, version))
105 for key,item
in self.ips_for_proxy.items():
106 entry = entry.replace(key,item)
107 temp_connect.append(entry.replace(key,item))
108 self.
connect = tuple(temp_connect)
117 if os.path.isdir(self.
baseDir)
and all(os.path.isfile(self.
baseDir +
'/' + jar)
for jar
in self.
jars):
122 self.
workDir = OfflineConverter.CheckTempDirectory(os.path.join(os.environ[
'CMSSW_BASE'],
'tmp',
'confdb',self.
version))
125 self.
workDir = OfflineConverter.CheckTempDirectory(os.path.join(os.environ[
'TMP'],
'confdb',self.
version))
128 self.
workDir = tempfile.mkdtemp()
129 atexit.register(shutil.rmtree, self.
workDir)
131 version_website = requests.get(self.
baseUrl+
"/../confdb.version").text
132 jars_require_update =
True
133 if os.path.exists(os.path.join(self.
workDir,
"confdb.version")):
134 with open(os.path.join(self.
workDir,
"confdb.version"))
as f:
135 version_existing = f.read()
136 if version_existing==version_website:
137 jars_require_update =
False
139 if jars_require_update:
140 for jar
in self.
jars:
142 handle, temp = tempfile.mkstemp(dir = self.
workDir, prefix = jar +
'.')
144 request = requests.get(self.
baseUrl +
'/' + jar)
145 with open(temp,
'wb')
as f:
146 f.write(request.content)
147 os.rename(temp, self.
workDir +
'/' + jar)
149 handle, temp = tempfile.mkstemp(dir = self.
workDir, prefix =
"confdb.version" +
'.')
151 with open(temp,
'w')
as f:
152 f.write(version_website)
153 os.rename(temp,os.path.join(self.
workDir,
"confdb.version"))
157 sys.stderr.write(
"workDir = %s\n" % self.
workDir)
164 self.
javaCmd = (
'java',
'-cp',
':'.
join(self.
workDir +
'/' + jar
for jar
in self.
jars),
'-Djava.security.egd=file:///dev/urandom',
'-Doracle.jdbc.timezoneAsRegion=false',
'-Xss32M',
'confdb.converter.BrowserConverter' )
170 sys.stderr.write(
"\n" +
' '.
join(args) +
"\n\n" )
171 sub = subprocess.Popen(
174 stdout = subprocess.PIPE,
175 stderr = subprocess.PIPE,
177 universal_newlines =
True )
178 return sub.communicate()
181 sys.stdout.write(
"""Usage: %s OPTIONS
183 --v1|--v2|--v3|--v3-beta|--v3-test (specify the ConfDB version [default: v3])
185 --run3|--run2|--dev|--online|--adg (specify the target db [default: run3], online will only work inside p5 network)
188 --orcoff is a synonim of --adg
189 --offline is a synonim of --hltdev
191 --configId <id> (specify the configuration by id)
192 --configName <name> (specify the configuration by name)
193 --runNumber <run> (specify the configuration by run number)
194 [exactly one of --configId OR --configName OR --runNumber is required]
196 --cff (retrieve configuration *fragment*)
197 --input <f1.root[,f2.root]> (insert PoolSource with specified fileNames)
198 --input <files.list> (read a text file which lists input ROOT files)
199 --output <out.root> (insert PoolOutputModule w/ specified fileName)
200 --nopsets (exclude all globale psets)
201 --noedsources (exclude all edsources)
202 --noes (exclude all essources *and* esmodules)
203 --noessources (exclude all essources)
204 --noesmodules (exclude all esmodules)
205 --noservices (exclude all services)
206 --nooutput (exclude all output modules)
207 --nopaths (exclude all paths [+=referenced seqs&mods])
208 --nosequences (don't define sequences [+=referenced s&m])
209 --nomodules (don't define modules)
210 --psets <pset1[,pset2]> (include only specified global psets)
211 --psets <-pset1[,-pset2]> (include all global psets but the specified)
212 --essources <ess1[,ess2]> (include only specified essources)
213 --essources <-ess1[,-ess2]> (include all essources but the specified)
214 --esmodules <esm1[,esm2]> (include only specified esmodules)
215 --esmodules <-esm1[,-esm2]> (include all esmodules but the specified)
216 --services <svc1[,svc2]> (include only specified services)
217 --services <-svc1[,-svc2]> (include all services but the specified)
218 --paths <p1[,p2]> (include only specified paths)
219 --paths <-p1[,-p2]> (include all paths but the specified)
220 --streams <s1[,s2]> (include only specified streams)
221 --datasets <d1[,d2]> (include only specified datasets)
222 --sequences <s1[,s2]> (include sequences, referenced or not!)
223 --modules <p1[,p2]> (include modules, referenced or not!)
224 --blocks <m1::p1[,p2][,m2]> (generate parameter blocks)
226 --verbose (print additional details)
240 if '--help' in args
or '-h' in args:
244 if '--verbose' in args:
246 args.remove(
'--verbose')
249 db_count = arg_count[
'--v1'] + arg_count[
'--v2'] + arg_count[
'--v3'] + arg_count[
'--v3-beta'] + arg_count[
'--v3-test']
251 sys.stderr.write(
'ERROR: conflicting database version specifications: "--v1", "--v2", "--v3", "--v3-beta", and "--v3-test" are mutually exclusive options' )
269 if '--v3-beta' in args:
272 args.remove(
'--v3-beta')
274 if '--v3-test' in args:
277 args.remove(
'--v3-test')
280 proxy_host =
"localhost"
282 if '--dbproxy' in args:
284 args.remove(
'--dbproxy')
285 if '--dbproxyhost' in args:
286 proxy_host = args.pop(args.index(
'--dbproxyhost')+1)
287 args.remove(
'--dbproxyhost')
288 if '--dbproxyport' in args:
289 proxy_port = args.pop(args.index(
'--dbproxyport')+1)
290 args.remove(
'--dbproxyport')
294 _dbs[
'v1'] = [
'--%s' % _db
for _db
in OfflineConverter.databases[
'v1'] ] + [
'--runNumber' ]
295 _dbs[
'v2'] = [
'--%s' % _db
for _db
in OfflineConverter.databases[
'v2'] ] + [
'--runNumber' ]
296 _dbs[
'v3'] = [
'--%s' % _db
for _db
in OfflineConverter.databases[
'v3'] ] + [
'--runNumber']
297 _dbs[
'v3-beta'] = [
'--%s' % _db
for _db
in OfflineConverter.databases[
'v3-beta'] ] + [
'--runNumber' ]
298 _dbs[
'v3-test'] = [
'--%s' % _db
for _db
in OfflineConverter.databases[
'v3-test'] ] + [
'--runNumber' ]
299 _dbargs = set(args) & set(sum(_dbs.values(), []))
303 sys.stderr.write(
"ERROR: too many database specifications: \"" +
"\", \"".
join( _dbargs) +
"\"\n" )
308 if db ==
'runNumber':
313 if not db
in OfflineConverter.databases[version]:
314 sys.stderr.write(
"ERROR: database version \"%s\" incompatible with specification \"%s\"\n" % (version, db) )
317 converter =
OfflineConverter(version = version, database = db, verbose = verbose,
318 proxy = proxy, proxyHost = proxy_host, proxyPort=proxy_port)
319 out, err = converter.query( * args )
321 sys.stderr.write(
"%s: error while retriving the HLT menu\n\n%s\n\n" % (sys.argv[0], err) )
324 sys.stdout.write( out )
327 if __name__ ==
"__main__":
std::function< unsigned int(align::ID)> Counter
static std::string join(char **cmd)