1 |
gutsche |
1.1 |
#!/usr/bin/env python
|
2 |
|
|
|
3 |
|
|
import sys, getopt, string
|
4 |
|
|
|
5 |
|
|
from FwkJobRep.ReportParser import readJobReport
|
6 |
|
|
|
7 |
|
|
def main(argv) :
|
8 |
|
|
"""
|
9 |
|
|
parseCrabFjr
|
10 |
|
|
|
11 |
|
|
parse CRAB FrameworkJobReport on WN and return parameters to WN wrapper script
|
12 |
|
|
|
13 |
|
|
prints information separated by semi-colon in fixed order:
|
14 |
|
|
|
15 |
|
|
1. ExitStatus (0 or ExitStatus from CMSSW)
|
16 |
|
|
|
17 |
|
|
required parameters:
|
18 |
|
|
--input : input FJR xml file
|
19 |
|
|
|
20 |
|
|
optional parameters:
|
21 |
|
|
--help : help
|
22 |
|
|
--debug : debug statements
|
23 |
|
|
|
24 |
|
|
"""
|
25 |
|
|
|
26 |
|
|
# defaults
|
27 |
|
|
input = ''
|
28 |
|
|
debug = 0
|
29 |
|
|
|
30 |
|
|
try:
|
31 |
|
|
opts, args = getopt.getopt(argv, "", ["input=", "debug", "help"])
|
32 |
|
|
except getopt.GetoptError:
|
33 |
|
|
print main.__doc__
|
34 |
|
|
sys.exit(2)
|
35 |
|
|
|
36 |
|
|
# check command line parameter
|
37 |
|
|
for opt, arg in opts :
|
38 |
|
|
if opt == "--help" :
|
39 |
|
|
print main.__doc__
|
40 |
|
|
sys.exit()
|
41 |
|
|
elif opt == "--input" :
|
42 |
|
|
input = arg
|
43 |
|
|
elif opt == "--debug" :
|
44 |
|
|
debug = 1
|
45 |
|
|
|
46 |
|
|
if input == '':
|
47 |
|
|
print main.__doc__
|
48 |
|
|
sys.exit()
|
49 |
|
|
|
50 |
|
|
# load FwkJobRep
|
51 |
|
|
jobReport = readJobReport(input)[0]
|
52 |
|
|
|
53 |
|
|
report = []
|
54 |
|
|
|
55 |
|
|
# get ExitStatus of last error
|
56 |
|
|
if len(jobReport.errors) != 0 :
|
57 |
|
|
report.append(str(jobReport.errors[-1]['ExitStatus']))
|
58 |
|
|
else :
|
59 |
|
|
report.append(str(0))
|
60 |
|
|
|
61 |
|
|
# get i/o statistics
|
62 |
|
|
storageStatistics = str(jobReport.storageStatistics)
|
63 |
|
|
|
64 |
|
|
print ';'.join(report)
|
65 |
|
|
|
66 |
|
|
|
67 |
|
|
|
68 |
|
|
if __name__ == '__main__' :
|
69 |
|
|
main(sys.argv[1:])
|
70 |
|
|
|
71 |
|
|
|