ATLAS Offline Software
diffConfigs.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 
5 # @file: diffConfigs.py
6 # @purpose: check that 2 ConfigurationShelves have same content (both in
7 # configurables and properties)
8 # @author: Sebastien Binet <binet@cern.ch>
9 # @date: September 2008
10 #
11 # @example:
12 #
13 # diffConfigs ref.pkl chk.pkl
14 #
15 
16 from __future__ import print_function
17 
18 __author__ = "Sebastien Binet"
19 
20 import sys
21 import os
22 
23 from optparse import OptionParser
24 
25 if __name__ == "__main__":
26 
27  parser = OptionParser(usage="usage: %prog [options] [-r] ref.pkl [-f] chk.pkl")
28  parser.add_option( "-r",
29  "--ref",
30  dest = "refFileName",
31  help = "The path to the first ConfigurationShelve file to analyze" )
32  parser.add_option( "-f",
33  "--file",
34  dest = "fileName",
35  help = "The path to the second ConfigurationShelve file to analyze" )
36  parser.add_option( "-v",
37  "--verbose",
38  action = "store_true",
39  dest = "verbose",
40  default = False,
41  help = "Switch to activate verbose printout" )
42 
43 
44  (options, args) = parser.parse_args()
45 
46  if len(args) > 0 and args[0][0] != "-":
47  options.refFileName = args[0]
48  pass
49  if len(args) > 1 and args[1][0] != "-":
50  options.fileName = args[1]
51  pass
52 
53  if options.fileName is None or options.refFileName is None :
54  str(parser.print_help() or "")
55  sys.exit(1)
56  pass
57 
58  chkFileName = os.path.expandvars(os.path.expanduser(options.fileName))
59  refFileName = os.path.expandvars(os.path.expanduser(options.refFileName))
60 
61  print ("::: comparing configurations:")
62  print ("::: ref: %s" % refFileName)
63  print ("::: chk: %s" % chkFileName)
64  from AthenaCommon.ConfigurationShelve import cmpConfigs
65  ref, chk, report = cmpConfigs (ref=refFileName,
66  chk=chkFileName)
67  if len(report)==0:
68  print ("::: all good")
69  sys.exit(0)
70 
71  for l in report: print (l)
72  print ("::: configurations differ !")
73  sys.exit(1)
str
Definition: BTagTrackIpAccessor.cxx:11