ATLAS Offline Software
trigconf_property.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 
3 # Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
4 """Usage: trigconf_property.py [Options] COMPONENT PROPERTY SMK [SMK2 ...]')
5 
6 Read trigger configuration properties from DB. SQL wildcards ('%') can be used to
7 print all matching components/properties.
8 
9 Example: trigconf_property.py Trig% OutputLevel 1178
10 """
11 
12 __author__ = "Frank Winklmeier"
13 
14 import sys
15 from TrigConfigSvc.TrigConfigSvcUtils import getPropertyFromDB
16 
17 def myhelp(option, opt_str, value, parser):
18  """Custom help callback since optparse does not preserve newlines"""
19 
20  print(__doc__)
21  parser.print_help()
22  sys.exit(1)
23 
24 
25 def main():
26  import optparse
27  parser = optparse.OptionParser(usage='', add_help_option=False)
28 
29  parser.add_option('-d', '--db', type='string', action='store', default='TRIGGERDB',
30  help='Trigger DB alias [%default]')
31 
32  parser.add_option('-s', '--short', action='store_true',
33  help='Only print property values')
34 
35  parser.add_option('--l2', action='store_true', help='Only show L2')
36  parser.add_option('--ef', action='store_true', help='Only show EF')
37  parser.add_option("-h", "--help", action="callback", callback=myhelp)
38 
39  (opts, args) = parser.parse_args()
40 
41  if len(args)<3:
42  parser.print_help()
43  return 1
44 
45  comp = args[0]
46  prop = args[1]
47  smk = args[2:]
48 
49  res = getPropertyFromDB(opts.db, smk, comp, prop)
50  if len(res)==0:
51  print('Cannot find property in DB')
52  return 2
53 
54  # Filter L2/EF
55  if opts.l2 is True and not opts.ef: res = filter(lambda x: x[4]=='L2',res)
56  if opts.ef is True and not opts.l2: res = filter(lambda x: x[4]=='EF',res)
57 
58  for p in res:
59  if opts.short:
60  print(p[3])
61  else:
62  print('%s %d %s %s %s' % (p[4],p[0],p[1],p[2],p[3]))
63 
64 
65 if __name__ == '__main__':
66  try:
67  sys.exit(main())
68  except KeyboardInterrupt:
69  sys.exit(1)
covarianceTool.filter
filter
Definition: covarianceTool.py:514
python.TrigConfigSvcUtils.getPropertyFromDB
def getPropertyFromDB(connection, smk, component, parameter)
Definition: TrigConfigSvcUtils.py:396
Muon::print
std::string print(const MuPatSegment &)
Definition: MuonTrackSteering.cxx:28
trigconf_property.main
def main()
Definition: trigconf_property.py:25
trigconf_property.myhelp
def myhelp(option, opt_str, value, parser)
Definition: trigconf_property.py:17