test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
contentValuesCheck.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 
3 from contentValuesLib import *
4 
5 class OptionParser(optparse.OptionParser):
6  """ Option parser class """
7  def __init__(self):
8  optparse.OptionParser.__init__(self, usage="%prog [options] root_file ...", version="%prog 0.0.1", conflict_handler="resolve")
9  self.add_option("--silent", "-s", action="store_true", dest="silent", default=False, help="silent mode: specify return code and exit")
10  self.add_option("--subsystem", "-c", action="store", type="string", dest="subsystem", default=None, help="Specify test subsystem")
11 
12 if __name__ == "__main__":
13 
14  # Create option parser and get options/arguments
15  optManager = OptionParser()
16  (opts, args) = optManager.parse_args()
17  opts = opts.__dict__
18 
19  # Check if at least one root file defined (can be many!)
20  if len(args) == 0:
21  print "At least one ROOT file must be priovided, use --help for hit"
22  sys.exit(1)
23 
24  # Check if all files exists and are accessible
25  for rfile in args:
26  try:
27  os.stat(rfile)
28  except:
29  print "File [", rfile, "] not exists or is not accessible?"
30  sys.exit(2)
31 
32  ss = opts['subsystem']
33 
34  # Lets extract values from files one-by-one, construct hashmap and check values
35  for rfile in args:
36 
37  (run_number, values) = getSummaryValues(file_name = rfile, shift_type = None, translate = False, filters = None)
38 
39  if values == None or len(values) == 0:
40  print "No content summary values found. Skipping file: %s" % rfile
41  continue
42 
43  messages = []
44  for sub in SUBSYSTEMS.keys():
45 
46  if not ss == None and not sub == ss:
47  continue
48 
49  if sub not in values:
50  messages.append("%s: missing subsystem!" % sub)
51  continue
52 
53  skeys = {}
54  sfolders = []
55 
56  for folder in FOLDERS.keys():
57 
58  if folder not in values[sub]:
59  messages.append("%s: missing folder EventInfo/%s" % (sub, folder))
60  continue
61 
62  if len(values[sub][folder]) == 0:
63  messages.append("%s: empty folder EventInfo/%s" % (sub, FOLDERS[folder][1]))
64  continue
65 
66  sfolders.append(folder)
67 
68  if 'Summary' not in values[sub][folder]:
69  messages.append("%s: missing summary value EventInfo/%s" % (sub, FOLDERS[folder][1]))
70 
71  for key in values[sub][folder].keys():
72  if key == 'Summary':
73  continue
74  if key not in skeys:
75  skeys[key] = []
76  skeys[key].append(folder)
77 
78  for key in skeys:
79  nfound = []
80  for folder in sfolders:
81  if skeys[key].count(folder) == 0: nfound.append(folder)
82  if len(nfound) > 0:
83  messages.append("%s: value (%s)/%s not found in (%s)" % (sub, ','.join(skeys[key]), key, ','.join(nfound)))
84 
85  if not opts['silent']:
86  for message in sorted(messages): print message
87  print "%d errors found" % len(messages)
88 
89  if len(messages) > 0: sys.exit(1)
90 
91  sys.exit(0)
92 
93 
boost::dynamic_bitset append(const boost::dynamic_bitset<> &bs1, const boost::dynamic_bitset<> &bs2)
this method takes two bitsets bs1 and bs2 and returns result of bs2 appended to the end of bs1 ...
static std::string join(char **cmd)
Definition: RemoteFile.cc:18