1 |
amott |
1.1 |
#!/usr/bin/env python
|
2 |
|
|
|
3 |
|
|
import os
|
4 |
|
|
import sys
|
5 |
|
|
import getopt
|
6 |
|
|
from MenuAnalyzer import MenuAnalyzer
|
7 |
amott |
1.2 |
from termcolor import colored, cprint
|
8 |
amott |
1.1 |
|
9 |
|
|
def usage():
|
10 |
|
|
print "Usage: "+sys.arg[0]+" <path to cdaq area>"
|
11 |
|
|
print "Options: "
|
12 |
|
|
print "-v Verbose mode (print out ALL checks)"
|
13 |
|
|
print "--doAnalysis=<analysis> Specify a specific check to so (default: do all)"
|
14 |
|
|
|
15 |
|
|
def main():
|
16 |
|
|
try:
|
17 |
|
|
opt, args = getopt.getopt(sys.argv[1:],"v",["doAnalysis="])
|
18 |
|
|
|
19 |
|
|
except getopt.GetoptError, err:
|
20 |
|
|
print str(err)
|
21 |
|
|
usage()
|
22 |
|
|
sys.exit(2)
|
23 |
|
|
|
24 |
|
|
if len(args)<1:
|
25 |
|
|
usage()
|
26 |
|
|
sys.exit()
|
27 |
|
|
|
28 |
|
|
menu = args[0]
|
29 |
|
|
verbose = False
|
30 |
|
|
toDo = []
|
31 |
|
|
for o,a in opt: # get options passed on the command line
|
32 |
|
|
if o=="-v":
|
33 |
|
|
Verbose = True
|
34 |
|
|
elif o=="--doAnalysis":
|
35 |
|
|
toDo.append(a)
|
36 |
|
|
else:
|
37 |
|
|
print "\nUnknown option "+o
|
38 |
|
|
sys.exit()
|
39 |
|
|
|
40 |
|
|
|
41 |
|
|
analyzer = MenuAnalyzer(menu)
|
42 |
|
|
if len(toDo)==0: analyzer.AddAllAnalyses()
|
43 |
|
|
else:
|
44 |
|
|
for a in toDo: analyzer.AddAnalysis(a)
|
45 |
|
|
analyzer.Analyze()
|
46 |
|
|
|
47 |
|
|
## check the results
|
48 |
amott |
1.2 |
if not analyzer.expressType=='':
|
49 |
|
|
print "\nEXPRESS Reconstruction will be: %s" % analyzer.expressType
|
50 |
|
|
else:
|
51 |
|
|
print "WARNING: Cannot determine express reconstruction"
|
52 |
|
|
|
53 |
|
|
print "\n"
|
54 |
amott |
1.1 |
failed=[]
|
55 |
amott |
1.2 |
format = "ANALYSIS%26s %s"
|
56 |
|
|
pass_txt = colored("SUCCEEDED",'green')
|
57 |
|
|
fail_txt = colored("FAILED",'red')
|
58 |
amott |
1.1 |
for analysis,result in analyzer.Results.iteritems():
|
59 |
|
|
if isinstance(result,list): # list output
|
60 |
|
|
if len(result) == 0:
|
61 |
amott |
1.2 |
print format % (analysis,pass_txt,)
|
62 |
amott |
1.1 |
else:
|
63 |
amott |
1.2 |
print format % (analysis,fail_txt,)
|
64 |
amott |
1.1 |
failed.append(analysis)
|
65 |
|
|
else:
|
66 |
|
|
if result==0:
|
67 |
amott |
1.2 |
print format % (analysis,pass_txt,)
|
68 |
amott |
1.1 |
else:
|
69 |
amott |
1.2 |
print format % (analysis,fail_txt,)
|
70 |
amott |
1.1 |
failed.append(analysis)
|
71 |
|
|
|
72 |
amott |
1.2 |
|
73 |
|
|
if len(failed)!=0: print "\nLIST OF FAILED ANALYSES:"
|
74 |
amott |
1.1 |
for analysis in failed:
|
75 |
amott |
1.2 |
print analyzer.ProblemDescriptions[analysis]+": "+str(analyzer.Results[analysis])
|
76 |
amott |
1.1 |
|
77 |
|
|
|
78 |
|
|
if __name__=='__main__':
|
79 |
|
|
main()
|