ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/CRAB/python/fillCrabFjr.py
Revision: 1.9
Committed: Sat May 12 13:48:22 2012 UTC (12 years, 11 months ago) by belforte
Content type: text/x-python
Branch: MAIN
CVS Tags: CRAB_2_9_1, CRAB_2_9_1_pre2, CRAB_2_9_1_pre1, CRAB_2_9_0, CRAB_2_9_0_pre2, CRAB_2_9_0_pre1, CRAB_2_8_8, CRAB_2_8_8_pre1, CRAB_2_8_7_patch3, CRAB_2_8_7_patch2, CRAB_2_8_7_patch1, CRAB_2_8_7, CRAB_2_8_7_pre2, CRAB_2_8_7_pre1, CRAB_2_8_6, CRAB_2_8_6_pre1, CRAB_2_8_5_patch3, CRAB_2_8_5_patch2, CRAB_2_8_5_patch1, CRAB_2_8_5, CRAB_2_8_5_pre5, CRAB_2_8_5_pre4, CRAB_2_8_5_pre3, CRAB_2_8_4_patch3, CRAB_2_8_5_pre2, CRAB_2_8_4_patch2, CRAB_2_8_5_pre1, CRAB_2_8_4_patch1, CRAB_2_8_4, CRAB_2_8_4_pre5, CRAB_2_8_4_pre4, CRAB_2_8_4_pre3, CRAB_2_8_4_pre2, CRAB_2_8_4_pre1, CRAB_2_8_3, CRAB_2_8_3_pre4, CRAB_2_8_3_pre3, CRAB_2_8_3_pre2, CRAB_2_8_3_pre1, CRAB_2_8_2_patch1, CRAB_2_8_2, CRAB_2_8_2_pre5, CRAB_2_8_2_pre4, CRAB_2_8_2_pre3, CRAB_2_8_2_pre2, HEAD
Changes since 1.8: +6 -8 lines
Error occurred while calculating annotation data.
Log Message:
fix for https://savannah.cern.ch/bugs/?94541: better validity check, notry-except-pass, only set status if --exitcode was used

File Contents

# Content
1 #!/usr/bin/env python
2 """
3 _fillCrabFjr.py
4
5 Adds to the FJR the WrapperExitCode and the ExeExitCode
6
7
8 """
9 import os, string
10 import sys
11
12 from ProdCommon.FwkJobRep.ReportParser import readJobReport
13 from ProdCommon.FwkJobRep.FwkJobReport import FwkJobReport
14
15 from ProdCommon.FwkJobRep.PerformanceReport import PerformanceReport
16
17 class fjrParser:
18 def __init__(self, argv):
19 if (len(argv))<2:
20 print "it is necessary to specify the fjr name"
21 sys.exit(2)
22 self.reportFileName = argv[1]
23 self.directive = argv[2]
24
25 if self.directive=='--errorcode':
26 self.wrapperExitCode = argv[3]
27 self.exeExitCode=''
28 if (len(argv))>4: self.exeExitCode = argv[4]
29
30 elif self.directive=='--timing':
31 self.wrapperTime = 'NULL'
32 self.exeTime = 'NULL'
33 self.stageoutTime = 'NULL'
34 self.cpuTime = 'NULL'
35 try:
36 self.wrapperTime = argv[3]
37 self.exeTime = argv[4]
38 self.stageoutTime = argv[5]
39 # pay attenition that the input env var is actually a string of 3 attrutes # Fabio
40 self.cpuTime = "%s %s %s"%(argv[6], argv[7], argv[8])
41 self.cpuTime.replace('"','').replace('&quot;','')
42 except:
43 pass
44 else:
45 print "bad directive specified"
46 sys.exit(2)
47 return
48
49 def run(self):
50
51 if not os.path.exists(self.reportFileName):
52 self.writeFJR()
53 else:
54 self.fillFJR()
55 if self.directive=='--errorcode':
56 self.setStatus()
57
58 return
59
60 def setStatus(self):
61 """
62 """
63 if (self.wrapperExitCode == '0') and (self.exeExitCode == '0'):
64 status = 'Success'
65 else:
66 status = 'Failed'
67
68 jobReport = readJobReport(self.reportFileName)[0]
69 jobReport.status = status
70 jobReport.write(self.reportFileName)
71
72 return
73
74 def writeFJR(self):
75 """
76 """
77 fwjr = FwkJobReport()
78 fwjr.addError(self.wrapperExitCode, "WrapperExitCode")
79 if (self.exeExitCode != ""):
80 fwjr.addError(self.exeExitCode, "ExeExitCode")
81 fwjr.write(self.reportFileName)
82
83 return
84
85 def checkValidFJR(self):
86 """
87 """
88 valid = 0
89 fjr=readJobReport(self.reportFileName)
90 if len(fjr) > 0 : valid = 1
91
92 return valid
93
94 def fillFJR(self):
95 """
96 """
97 valid = self.checkValidFJR()
98 if valid == 1 and self.directive=='--errorcode':
99 jobReport = readJobReport(self.reportFileName)[0]
100 if (len(jobReport.errors) > 0):
101 error = 0
102 for err in jobReport.errors:
103 if err['Type'] == "WrapperExitCode" :
104 err['ExitStatus'] = self.wrapperExitCode
105 jobReport.write(self.reportFileName)
106 error = 1
107 if (self.exeExitCode != ""):
108 if err['Type'] == "ExeExitCode" :
109 err['ExitStatus'] = self.exeExitCode
110 jobReport.write(self.reportFileName)
111 error = 1
112 if (error == 0):
113 jobReport.addError(self.wrapperExitCode, "WrapperExitCode")
114 if (self.exeExitCode != ""):
115 jobReport.addError(self.exeExitCode, "ExeExitCode")
116 jobReport.write(self.reportFileName)
117 else:
118 jobReport.addError(self.wrapperExitCode, "WrapperExitCode")
119 if (self.exeExitCode != ""):
120 jobReport.addError(self.exeExitCode, "ExeExitCode")
121 jobReport.write(self.reportFileName)
122
123 elif valid == 1 and self.directive=='--timing':
124 jobReport = readJobReport(self.reportFileName)[0]
125 # add here timing settings
126 perf = jobReport.performance
127 perf.addSummary("CrabTiming", WrapperTime = self.wrapperTime, ExeTime = self.exeTime,\
128 StageoutTime = self.stageoutTime, CpuTime = self.cpuTime)
129 jobReport.write(self.reportFileName)
130 pass
131 else:
132 self.writeFJR()
133
134 if __name__ == '__main__':
135
136 FjrParser_ = fjrParser(sys.argv)
137 FjrParser_.run()
138