ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/RateMonShiftTool_dev/MenuChecker.py
Revision: 1.1
Committed: Thu Jul 12 16:04:24 2012 UTC (12 years, 9 months ago) by amott
Content type: text/x-python
Branch: MAIN
Log Message:
initial versions of tools to check menu consistencies

File Contents

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