ATLAS Offline Software
CheckTagAssociation.py
Go to the documentation of this file.
1 #!/bin/env python
2 
3 # Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
4 #
5 # CheckTagAssociation.py
6 # Andrei Artamonov 2012
7 #==================================================
8 
9 import sys, getopt
10 tagusefile='/afs/cern.ch/user/a/atlcond/notify/AtlCoolMerge.taguse'
11 
12 
13 options, remainder = getopt.getopt(sys.argv[1:], 'h', ['help','folder=','globaltag=','instance=','localtag=','schema=','server='])
14 
15 # defaults
16 folder=''
17 #globaltag='CURRENT'
18 globaltag=''
19 localtag=''
20 server = ''
21 instance = 'CONDBR2'
22 schema = "COOLOFL_TILE"
23 help = 0
24 for opt, arg in options:
25  arg = arg.strip()
26  if opt in ('-h'):
27  help = 1
28  elif opt in ('--help'):
29  help = 1
30  elif opt in ('--folder'):
31  folder = arg
32  elif opt in ('--globaltag'):
33  globaltag = arg
34  elif opt in ('--localtag'):
35  localtag = arg
36  elif opt in ('--instance'):
37  instance = arg
38  elif opt in ('--schema'):
39  schema = arg
40  elif opt in ('--server'):
41  server = a
42 
43 if 'ONL01' in folder:
44  print (' it does not work with singleversion folders')
45  sys.exit(0)
46 
47 if help:
48  print (' This script prints aliases for CURRENT and NEXT global tags')
49  print (' if no options are provided and also resolves global tag ')
50  print (' to leaf tag if')
51  print (' folder is provided. By default, if global tag is not specified,')
52  print (' globaltag=CURRENT')
53  print (' if local tag is specified, it makes inverse operation - ')
54  print (' shows all global tags linked to local tag')
55  print (' localtag=')
56  print (' default instance=CONDBR2')
57  print (' usage:')
58  print (' CheckTagAssociation.py --folder=foldername --globaltag=tagname --instance=instancename --localtag=leaftagname')
59  print ("options globaltag and localtag are mutually exclusive")
60  print (" if both are specified, globaltag is ignored and ")
61  print (" association of localtag to all global tags is printed")
62  print (" EXAMPLES: ")
63  print ("CheckTagAssociation.py --folder=/TILE/OFL02/CALIB/CES --localtag=TileOfl02CalibCes-RUN2-HLT-UPD1-01")
64  print ("CheckTagAssociation.py --folder=/TILE/OFL02/CALIB/CES")
65  sys.exit()
66 
67 
68 from TileCalibBlobPython import TileCalibTools
69 current = TileCalibTools.getAliasFromFile('Current')
70 nexttag = TileCalibTools.getAliasFromFile('Next')
71 #--------------------------------
72 from TileCalibBlobPython.TileCalibLogger import getLogger
73 log = getLogger("TileCalibTools")
74 import logging
75 log.setLevel(logging.WARNING)
76 
77 
78 #if instance == 'CONDBR2' :
79 print ("alias CURRENT = %s alias NEXT = %s" % (current, nexttag))
80 
81 if folder == '':
82  sys.exit()
83 
84 #=================================================
85 connStr=schema+'/'+instance
86 
87 #=== open the database
88 db = TileCalibTools.openDbConn(connStr, server)
89 
90 if localtag == "" :
91  #=== resolve folder tag from global tag
92  if globaltag != "":
93  foldertag = TileCalibTools.getFolderTag(db, folder, globaltag)
94  print ("global tag %s associated to leaf TAG %s" % (globaltag,foldertag))
95  else:
96  foldertag = TileCalibTools.getFolderTag(db, folder, current)
97  print ("global tag %s associated to leaf TAG %s" % (current,foldertag))
98  foldertag = TileCalibTools.getFolderTag(db, folder, nexttag)
99  print ("global tag %s associated to leaf TAG %s" % (nexttag,foldertag))
100 
101 else:
102  rfolder=db.getFolderSet('/')
103  taglist=rfolder.listTags()
104  #print (taglist)
105  notfound=True
106  for tag in taglist:
107  try:
108  foldertag = TileCalibTools.getFolderTag(db, folder, str(tag))
109  if localtag == foldertag:
110  print (" leaf tag %s linked to global tag %s " % (localtag, tag))
111  notfound=False
112  except Exception:
113  pass
114  if notfound:
115  print (" leaf tag %s is not linked to any global tag" % localtag)
str
Definition: BTagTrackIpAccessor.cxx:11
python.CaloCondLogger.getLogger
def getLogger(name="CaloCond")
Definition: CaloCondLogger.py:16