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',
50 'cmsonr1-adg1-s.cern.ch' :
'10.116.96.109',
51 'cmsonr1-s.cms' :
'10.176.84.78' 54 databases[
'v3-beta'] = dict(databases[
'v3'])
55 databases[
'v3-test'] = dict(databases[
'v3'])
56 databases[
'v2'] = dict(databases[
'v3'])
58 for dbkey
in databases[
'v2']:
59 dbparams = databases[
'v2'][dbkey]
60 if dbparams[3]==
'cmsr1-s.cern.ch,cmsr2-s.cern.ch,cmsr3-s.cern.ch':
61 databases[
'v2'][dbkey] = dbparams[0:3]+(
'cmsr1-s.cern.ch',)+dbparams[4:]
65 dir = os.path.realpath(dir)
66 if not os.path.isdir(dir):
74 def __init__(self, version = 'v3', database = 'run3', url = None, verbose = False,
75 proxy = False, proxyHost = 'localhost', proxyPort = '8080',
76 tunnel = False, tunnelPort = '10121'):
79 self.
baseDir =
'/afs/cern.ch/user/c/confdb/www/%s/lib' % version
80 self.
baseUrl =
'https://confdb.web.cern.ch/confdb/%s/lib' % version
81 self.
jars = (
'ojdbc8.jar',
'cmssw-evf-confdb-converter.jar' )
84 self.
jars = (
'ojdbc6.jar',
'cmssw-evf-confdb-converter.jar' )
93 sys.stderr.write(
"ERROR: proxy and tunnel options can not both be true" )
99 sys.stderr.write(
"ERROR: unsupported database version \"%s\"\n" % version)
107 sys.stderr.write(
"ERROR: unknown database \"%s\" for version \"%s\"\n" % (database, version))
115 entry = entry.replace(key,item)
116 temp_connect.append(entry.replace(key,item))
123 temp_connect = list(self.
connect)
124 host_index = temp_connect.index(
'-h')
125 temp_connect[host_index+1] =
"localhost" 136 if os.path.isdir(self.
baseDir)
and all(os.path.isfile(self.
baseDir +
'/' + jar)
for jar
in self.
jars):
141 self.
workDir = OfflineConverter.CheckTempDirectory(os.path.join(os.environ[
'CMSSW_BASE'],
'tmp',
'confdb',self.
version))
144 self.
workDir = OfflineConverter.CheckTempDirectory(os.path.join(os.environ[
'TMP'],
'confdb',self.
version))
147 self.
workDir = tempfile.mkdtemp()
148 atexit.register(shutil.rmtree, self.
workDir)
150 version_website = requests.get(self.
baseUrl+
"/../confdb.version").text
151 jars_require_update =
True 152 if os.path.exists(os.path.join(self.
workDir,
"confdb.version")):
153 with open(os.path.join(self.
workDir,
"confdb.version"))
as f:
154 version_existing = f.read()
155 if version_existing==version_website:
156 jars_require_update =
False 158 if jars_require_update:
159 for jar
in self.
jars:
161 handle, temp = tempfile.mkstemp(dir = self.
workDir, prefix = jar +
'.')
163 request = requests.get(self.
baseUrl +
'/' + jar)
164 with open(temp,
'wb')
as f:
165 f.write(request.content)
166 os.rename(temp, self.
workDir +
'/' + jar)
168 handle, temp = tempfile.mkstemp(dir = self.
workDir, prefix =
"confdb.version" +
'.')
170 with open(temp,
'w')
as f:
171 f.write(version_website)
172 os.rename(temp,os.path.join(self.
workDir,
"confdb.version"))
176 sys.stderr.write(
"workDir = %s\n" % self.
workDir)
183 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' )
189 sys.stderr.write(
"\n" +
' '.
join(args) +
"\n\n" )
190 sub = subprocess.Popen(
193 stdout = subprocess.PIPE,
194 stderr = subprocess.PIPE,
196 universal_newlines =
True )
197 return sub.communicate()
200 sys.stdout.write(
"""Usage: %s OPTIONS 202 --v1|--v2|--v3|--v3-beta|--v3-test (specify the ConfDB version [default: v3]) 204 --run3|--run2|--dev|--online|--adg (specify the target db [default: run3], online will only work inside p5 network) 207 --orcoff is a synonim of --adg 208 --offline is a synonim of --hltdev 210 --configId <id> (specify the configuration by id) 211 --configName <name> (specify the configuration by name) 212 --runNumber <run> (specify the configuration by run number) 213 [exactly one of --configId OR --configName OR --runNumber is required] 215 --cff (retrieve configuration *fragment*) 216 --input <f1.root[,f2.root]> (insert PoolSource with specified fileNames) 217 --input <files.list> (read a text file which lists input ROOT files) 218 --output <out.root> (insert PoolOutputModule w/ specified fileName) 219 --nopsets (exclude all globale psets) 220 --noedsources (exclude all edsources) 221 --noes (exclude all essources *and* esmodules) 222 --noessources (exclude all essources) 223 --noesmodules (exclude all esmodules) 224 --noservices (exclude all services) 225 --nooutput (exclude all output modules) 226 --nopaths (exclude all paths [+=referenced seqs&mods]) 227 --nosequences (don't define sequences [+=referenced s&m]) 228 --nomodules (don't define modules) 229 --psets <pset1[,pset2]> (include only specified global psets) 230 --psets <-pset1[,-pset2]> (include all global psets but the specified) 231 --essources <ess1[,ess2]> (include only specified essources) 232 --essources <-ess1[,-ess2]> (include all essources but the specified) 233 --esmodules <esm1[,esm2]> (include only specified esmodules) 234 --esmodules <-esm1[,-esm2]> (include all esmodules but the specified) 235 --services <svc1[,svc2]> (include only specified services) 236 --services <-svc1[,-svc2]> (include all services but the specified) 237 --paths <p1[,p2]> (include only specified paths) 238 --paths <-p1[,-p2]> (include all paths but the specified) 239 --streams <s1[,s2]> (include only specified streams) 240 --datasets <d1[,d2]> (include only specified datasets) 241 --sequences <s1[,s2]> (include sequences, referenced or not!) 242 --modules <p1[,p2]> (include modules, referenced or not!) 243 --blocks <m1::p1[,p2][,m2]> (generate parameter blocks) 245 Options to connect to target db via SOCKS proxy, or direct tunnel: 246 [the options --dbproxy and --dbtunnel are mutually exclusive] 247 --dbproxy (use a SOCKS proxy to connect outside CERN network [default: False]) 248 --dbproxyhost <hostname> (host of the SOCKS proxy [default: "localhost"]) 249 --dbproxyport <port> (port of the SOCKS proxy [default: 8080]) 250 --dbtunnel (use direct tunnel to connect outside CERN network [default: False]) 251 --dbtunnelport <port> (port when using a direct tunnel on localhost [default: 10121]) 253 --verbose (print additional details) 267 if '--help' in args
or '-h' in args:
271 if '--verbose' in args:
273 args.remove(
'--verbose')
276 db_count = arg_count[
'--v1'] + arg_count[
'--v2'] + arg_count[
'--v3'] + arg_count[
'--v3-beta'] + arg_count[
'--v3-test']
278 sys.stderr.write(
'ERROR: conflicting database version specifications: "--v1", "--v2", "--v3", "--v3-beta", and "--v3-test" are mutually exclusive options' )
296 if '--v3-beta' in args:
299 args.remove(
'--v3-beta')
301 if '--v3-test' in args:
304 args.remove(
'--v3-test')
307 proxy_host =
"localhost" 309 if '--dbproxy' in args:
311 args.remove(
'--dbproxy')
312 if '--dbproxyhost' in args:
313 proxy_host = args.pop(args.index(
'--dbproxyhost')+1)
314 args.remove(
'--dbproxyhost')
315 if '--dbproxyport' in args:
316 proxy_port = args.pop(args.index(
'--dbproxyport')+1)
317 args.remove(
'--dbproxyport')
320 tunnel_port =
"10121" 321 if '--dbtunnel' in args:
323 args.remove(
'--dbtunnel')
325 if '--dbtunnelport' in args:
326 tunnel_port = args.pop(args.index(
'--dbtunnelport')+1)
327 args.remove(
'--dbtunnelport')
330 sys.stderr.write(
'ERROR: conflicting connection specifications, "--dbtunnel" and "--dbproxy" are mutually exclusive options\n' )
334 _dbs[
'v1'] = [
'--%s' % _db
for _db
in OfflineConverter.databases[
'v1'] ] + [
'--runNumber' ]
335 _dbs[
'v2'] = [
'--%s' % _db
for _db
in OfflineConverter.databases[
'v2'] ] + [
'--runNumber' ]
336 _dbs[
'v3'] = [
'--%s' % _db
for _db
in OfflineConverter.databases[
'v3'] ] + [
'--runNumber']
337 _dbs[
'v3-beta'] = [
'--%s' % _db
for _db
in OfflineConverter.databases[
'v3-beta'] ] + [
'--runNumber' ]
338 _dbs[
'v3-test'] = [
'--%s' % _db
for _db
in OfflineConverter.databases[
'v3-test'] ] + [
'--runNumber' ]
339 _dbargs = set(args) & set(sum(_dbs.values(), []))
343 sys.stderr.write(
"ERROR: too many database specifications: \"" +
"\", \"".
join( _dbargs) +
"\"\n" )
348 if db ==
'runNumber':
353 if not db
in OfflineConverter.databases[version]:
354 sys.stderr.write(
"ERROR: database version \"%s\" incompatible with specification \"%s\"\n" % (version, db) )
357 converter =
OfflineConverter(version = version, database = db, verbose = verbose,
358 proxy = proxy, proxyHost = proxy_host, proxyPort = proxy_port,
359 tunnel = tunnel, tunnelPort = tunnel_port)
360 out, err = converter.query( * args )
362 sys.stderr.write(
"%s: error while retrieving the HLT menu\n\n%s\n\n" % (sys.argv[0], err) )
365 sys.stdout.write( out )
368 if __name__ ==
"__main__":
def __init__(self, version='v3', database='run3', url=None, verbose=False, proxy=False, proxyHost='localhost', proxyPort='8080', tunnel=False, tunnelPort='10121')
def CheckTempDirectory(dir)
std::function< unsigned int(align::ID)> Counter
static std::string join(char **cmd)