3 from __future__
import print_function
11 countRE = re.compile (
r'^count_(\w+)')
12 avoid = [
'index',
'print']
15 """returns a tuple. First value is true if summary hasn't found
16 any problems, else false."""
19 compared = summary.get(
'eventsCompared', -1)
20 if len( summary) != 2:
22 for key,value
in six.iteritems(summary):
23 if countRE.search(key):
25 return (retval, {
'count':count,
'compared':compared})
27 if __name__ ==
"__main__":
30 percentRE = re.compile (
r'%')
31 startOutputRE = re.compile (
r'^Summary$')
32 success1RE = re.compile (
r"{'eventsCompared':\s+(\d+),\s+'count_(\S+)':\s+(\d+)\s*}")
33 success2RE = re.compile (
r"{'count_(\S+)':\s+(\d+),\s+'eventsCompared':\s+(\d+)\s*}")
34 loadingSoRE = re.compile (
r'loading (genobjectrootlibs/\w+)')
35 creatingSoRE = re.compile (
r'creating shared library (\S+)')
36 compRootRE = re.compile (
r' --compRoot=(\S+)')
37 descriptionRE = re.compile (
r'^edmOneToOneComparison.py (\w+).txt')
38 edmCommandRE = re.compile (
r'^(edmOneToOneComparison.py .+?)\s*$')
40 labelErrorRE = re.compile (
r"labelDict = GenObject._ntupleDict\[tupleName\]\['_label'\]")
41 missingLabelRE = re.compile (
r'not able to get')
42 terminatedRE = re.compile (
r'Terminated\s+\$EXE\s+\$@')
43 cppExceptionRE = re.compile (
r'\(C\+\+ exception\)')
44 missingCfgRE = re.compile (
r"raise.+Can't open configuration")
45 finishRE = re.compile (
r'finish')
46 dummyRE = re.compile (
r'edm::Wrapper<dummyType>')
47 noEdmWrapperRE = re.compile (
r"'ROOT' has no attribute 'edm::Wrapper")
48 uint32RE = re.compile (
r"Config file parser error 'operatoruint32_t")
49 nonSpacesRE = re.compile (
r'\S')
50 problemDict = {
'labelDict' : labelErrorRE,
51 'missingLabel' : missingLabelRE,
52 'terminate' : terminatedRE,
54 'cppException' : cppExceptionRE,
55 'missingCfg' : missingCfgRE,
56 'noEdmWrapper' : noEdmWrapperRE,
58 'operator' : re.compile (
r"onfig file parser error 'operator"),
59 'useless' : re.compile (
r'no member functions that are useful'),
60 'lazy' : re.compile (
r': Assertion'),
61 'detset' : re.compile (
r"AttributeError: 'edm::DetSet"),
62 'doubleint' : re.compile (
r'AttributeError: (int|double)'),
65 parser = optparse.OptionParser (
"Usage: %prog logfilePrefix [directory]")
66 parser.add_option (
"--counts", dest=
"counts",
67 action=
"store_true", default=
False,
68 help=
"Display counts only.")
69 parser.add_option (
'--mismatch', dest=
'mismatch',
71 help=
'Displays only mismatch output')
72 parser.add_option (
"--diffTree", dest=
"diffTree",
73 action=
"store_true", default=
False,
74 help=
"Shows diffTree printout.")
75 parser.add_option (
'--makeCompRoot', dest=
'makeCompRoot',
77 help=
'Prints commands to make compRoot files for difftree')
78 parser.add_option (
"--problem", dest=
"problem", type=
'string',
79 help=
"Displays problems matching PROBLEM")
81 options, args = parser.parse_args()
82 if not 1 <= len (args) <= 2:
83 raise RuntimeError(
"Must give directory and log file prefix")
84 logfilePrefix = percentRE.sub (
'*', args[0])
85 if logfilePrefix[-1] !=
'*':
92 files = glob (logfilePrefix)
96 for filename
in oldFiles:
97 files.append (logdir +
'/' + filename)
99 totalFiles = len (files)
113 source = open (log,
'r')
119 line = line.rstrip(
'\n')
120 match = edmCommandRE.search (line)
122 command = match.group(1)
123 match = loadingSoRE.search (line)
125 goShlib = match.group(1)
126 match = creatingSoRE.search (line)
128 goShlib = match.group(1)
130 match = descriptionRE.search (line)
132 objectName = match.group(1)
133 match = compRootRE.search (line)
135 compRoot = match.group(1)
136 match = loadingSoRE.search (line)
138 soName = match.group(1)
140 if not nonSpacesRE.search(line):
144 if startOutputRE.search(line):
148 if success1RE.search (line)
or success2RE.search(line):
151 for key, regex
in six.iteritems(problemDict):
153 if regex.search(line):
154 if key
in problemSet:
157 problems.setdefault(log,[]).
append(key)
158 if key
not in problemTypes:
159 problemTypes[key] = 1
161 problemTypes[key] += 1
166 summary = eval (summaryLines)
167 ok = summaryOK (summary)
176 successes[log] = pprint.pformat (summary, indent=4)
180 if log
not in problems
and not ok[0]:
181 if not ok[0]
and summary:
183 problems[log] = pprint.pformat (summary, indent=4)
185 if objectName
and compRoot
and soName:
187 varNames = summary.get(objectName, {}).\
188 get(
'_var', {}).
keys()
189 variables = [
'eta',
'phi']
190 for var
in sorted (varNames):
191 if var
not in variables
and var
not in avoid:
192 variables.append (var)
193 diffCmd =
'diffTreeTool.py --skipUndefined %s %s %s' \
194 % (compRoot, soName,
" ".
join(variables))
196 diffOutput[log] = diffCmd
198 problems[log] = [
'other',
'ran:%s' % ran,
199 'success:%s' % success]
201 if key
not in problemTypes:
202 problemTypes[key] = 1
204 problemTypes[key] += 1
205 mismatches = problemTypes.get(
'mismatch', 0)
206 if 'mismatch' in problemTypes:
207 del problemTypes[
'mismatch']
208 print(
"total: ", len (files))
209 print(
"success: ", succeeded)
210 print(
"mismatches: ", mismatches)
211 print(
"weird: ", weird)
212 print(
"Tool issue types:")
214 for key, value
in sorted (six.iteritems(problemTypes)):
215 print(
" %-15s: %4d" % (key, value))
217 print(
" ",
'-'*13,
" : ----")
218 print(
" %-15s: %4d + %d + %d + %d = %d" \
219 % (
'total', total, succeeded, mismatches, weird,
220 total + succeeded + mismatches + weird))
222 if not options.counts:
223 print(
"\nDetailed Problems list:")
224 for key, problemList
in sorted (six.iteritems(problems)):
225 if options.problem
and problemList[0] != options.problem:
227 if options.mismatch
and not isinstance (problemList, str):
230 print(
" %s:\n %s\n" % (key, problemList))
231 if options.mismatch
and goShlib
and compRoot:
232 print(
"diffTree %s %s" % (goShlib, compRoot))
233 diffCmd = diffOutput.get(key)
235 print(commands.getoutput (diffCmd))
236 if not options.problem
and not options.mismatch:
237 print(
"\n",
'='*78,
'\n')
238 print(
"Success list:")
239 for key, successesList
in sorted (six.iteritems(successes)):
240 print(
" %s:\n %s\n" % (key, successesList))