ATLAS Offline Software
Loading...
Searching...
No Matches
python.AtlCoolLib.coolTool Class Reference
Collaboration diagram for python.AtlCoolLib.coolTool:

Public Member Functions

 __init__ (self, name, readonly, minarg, maxarg, longopts)
 procopts (self, opts)

Public Attributes

 name = name
 readonly = readonly
bool runLumi = True
int runmin = 0
tuple runmax = (1 << 31)-1
int lumimin = 0
tuple lumimax = (1 << 32)-2
int tsmin = cool.ValidityKeyMin
int tsmax = cool.ValidityKeyMax
tuple since = cool.ValidityKeyMin
tuple until = cool.ValidityKeyMax
bool debug = False
 conn = transConn(str(args[0]))
 db = indirectOpen(self.conn,debug=self.debug)

Protected Member Functions

 _usage1 (self)
 _usage2 (self)
 _procopts (self, opts)

Detailed Description

Class coolTool implements a base for python command-line tools to access
and set data in COOL folders
Incomplete baseclass implementation - clients must implement the following:
 - setup(self,args) - set additional arguments
 - usage(self) - print usage
 - execute(self) - execute command
 - procopts(self,opts) - (optional) - process additional command switches

Definition at line 287 of file AtlCoolLib.py.

Constructor & Destructor Documentation

◆ __init__()

python.AtlCoolLib.coolTool.__init__ ( self,
name,
readonly,
minarg,
maxarg,
longopts )
Initialise class and process command line options and switches

Definition at line 297 of file AtlCoolLib.py.

297 def __init__(self,name,readonly,minarg,maxarg,longopts):
298 """
299 Initialise class and process command line options and switches
300 """
301 self.name=name
302 self.readonly=readonly
303 self.runLumi=True
304 self.runmin=0
305 self.runmax=(1 << 31)-1
306 self.lumimin=0
307 self.lumimax=(1 << 32)-2
308 self.tsmin=cool.ValidityKeyMin
309 self.tsmax=cool.ValidityKeyMax
310 self.since=cool.ValidityKeyMin
311 self.until=cool.ValidityKeyMax
312 self.debug=False
313 # get and process options - note only use long options format
314 try:
315 fullopts=longopts+['r=','rs=','ru=','l=','ls=','lu=','ts=','tu=','debug']
316 opts,args=getopt.getopt(sys.argv[1:],'',fullopts)
317 except getopt.GetoptError as e:
318 print (e)
319 self.usage()
320 sys.exit(1)
321 if len(args)<minarg or len(args)>maxarg:
322 print (name,'takes between',minarg,'and',maxarg,'non-optional parameters')
323 self.usage()
324 sys.exit(1)
325 # set standard parameters
326 self.conn=transConn(str(args[0]))
327 # allow derived class to set parameters
328 self.setup(args[1:])
329 self._procopts(opts)
330 self.procopts(opts)
331 # open database connection and execute command
332 if self.readonly:
333 self.db=indirectOpen(self.conn,debug=self.debug)
334 else:
335 self.db=forceOpen(self.conn)
336 self.execute()
337
std::string transConn(const std::string &inconn)

Member Function Documentation

◆ _procopts()

python.AtlCoolLib.coolTool._procopts ( self,
opts )
protected

Definition at line 355 of file AtlCoolLib.py.

355 def _procopts(self,opts):
356 # process the standard parameters
357 for o,a in opts:
358 if (o=='--rs'): self.runmin=int(a)
359 if (o=='--ru'): self.runmax=int(a)
360 if (o=='--r'):
361 self.runmin=int(a)
362 self.runmax=int(a)
363 if (o=='--ls'): self.lumimin=int(a)
364 if (o=='--lu'): self.lumimax=int(a)
365 if (o=='--l'):
366 self.lumimin=int(a)
367 self.lumimax=int(a)
368 if (o=='--ts'):
369 self.tsmin=timeVal(a)*1000000000
370 self.runLumi=False
371 if (o=='--tu'):
372 self.tsmax=timeVal(a)*1000000000
373 self.runLumi=False
374 if (o=='--debug'): self.debug=True
375 # now set the real interval of validity
376 if (self.runLumi):
377 print ('>== Data valid for run,LB [',self.runmin,',',self.lumimin,'] to [',self.runmax,',',self.lumimax,']')
378 self.since=(self.runmin << 32)+self.lumimin
379 self.until=(self.runmax << 32)+self.lumimax+1
380 else:
381 self.since=self.tsmin
382 self.until=self.tsmax
383 print ('>== Data valid for timestamps (sec) from ',self.since/1000000000,'(',timeString(self.since),') to ',self.until/1000000000,'(',timeString(self.until),')')
384 # check IOV is OK
385 if (self.until<self.since):
386 print ('ERROR in IOV definition: until<since')
387 sys.exit(1)
388

◆ _usage1()

python.AtlCoolLib.coolTool._usage1 ( self)
protected

Definition at line 338 of file AtlCoolLib.py.

338 def _usage1(self):
339 # base implementation of usage - first part
340 print ('Usage:',self.name,' {<options>} dbname ',)
341

◆ _usage2()

python.AtlCoolLib.coolTool._usage2 ( self)
protected

Definition at line 342 of file AtlCoolLib.py.

342 def _usage2(self):
343 # base implementation of usage - second part
344 print ('Options to specify IOV (default valid for all intervals)')
345 print ('--rs=<first run>')
346 print ('--ru=<last run> (inclusive)')
347 print ('--r=<run> (only single run)')
348 print ('--ls=<lumi block since>')
349 print ('--l=<lumi block> (only single LB)')
350 print ('--lu=<lumi block until> (inclusive)')
351 print ('--ts=<initial timestamp> (in seconds)')
352 print ('--tu=<final timestamp> (in seconds)')
353 print ('--debug: Enable debugging information')
354

◆ procopts()

python.AtlCoolLib.coolTool.procopts ( self,
opts )

Definition at line 389 of file AtlCoolLib.py.

389 def procopts(self,opts):
390 # default implementation of procopts - do nothing
391 pass
392
393

Member Data Documentation

◆ conn

python.AtlCoolLib.coolTool.conn = transConn(str(args[0]))

Definition at line 326 of file AtlCoolLib.py.

◆ db

python.AtlCoolLib.coolTool.db = indirectOpen(self.conn,debug=self.debug)

Definition at line 333 of file AtlCoolLib.py.

◆ debug

bool python.AtlCoolLib.coolTool.debug = False

Definition at line 312 of file AtlCoolLib.py.

◆ lumimax

python.AtlCoolLib.coolTool.lumimax = (1 << 32)-2

Definition at line 307 of file AtlCoolLib.py.

◆ lumimin

python.AtlCoolLib.coolTool.lumimin = 0

Definition at line 306 of file AtlCoolLib.py.

◆ name

python.AtlCoolLib.coolTool.name = name

Definition at line 301 of file AtlCoolLib.py.

◆ readonly

python.AtlCoolLib.coolTool.readonly = readonly

Definition at line 302 of file AtlCoolLib.py.

◆ runLumi

python.AtlCoolLib.coolTool.runLumi = True

Definition at line 303 of file AtlCoolLib.py.

◆ runmax

python.AtlCoolLib.coolTool.runmax = (1 << 31)-1

Definition at line 305 of file AtlCoolLib.py.

◆ runmin

python.AtlCoolLib.coolTool.runmin = 0

Definition at line 304 of file AtlCoolLib.py.

◆ since

python.AtlCoolLib.coolTool.since = cool.ValidityKeyMin

Definition at line 310 of file AtlCoolLib.py.

◆ tsmax

int python.AtlCoolLib.coolTool.tsmax = cool.ValidityKeyMax

Definition at line 309 of file AtlCoolLib.py.

◆ tsmin

int python.AtlCoolLib.coolTool.tsmin = cool.ValidityKeyMin

Definition at line 308 of file AtlCoolLib.py.

◆ until

python.AtlCoolLib.coolTool.until = cool.ValidityKeyMax

Definition at line 311 of file AtlCoolLib.py.


The documentation for this class was generated from the following file: