Revision: | 1.7 |
Committed: | Fri Oct 31 12:09:02 2008 UTC (16 years, 5 months ago) by slacapra |
Content type: | text/x-python |
Branch: | MAIN |
CVS Tags: | CRAB_2_6_6_pre6, CRAB_2_6_6_pre5, CRAB_2_6_6_pre4, CRAB_2_6_6_pre3, CRAB_2_6_6_pre2, CRAB_2_6_6_check, CRAB_2_6_6, CRAB_2_6_6_pre1, CRAB_2_7_0, CRAB_2_6_5, CRAB_2_7_0_pre8, CRAB_2_6_5_pre1, CRAB_2_7_0_pre7, CRAB_2_6_4, CRAB_2_7_0_pre6, CRAB_2_6_4_pre1, CRAB_2_7_0_pre5, CRAB_2_6_3_patch_2, CRAB_2_6_3_patch_2_pre2, CRAB_2_6_3_patch_2_pre1, CRAB_2_6_3_patch_1, CRAB_2_7_0_pre4, CRAB_2_7_0_pre3, CRAB_2_6_3, CRAB_2_6_3_pre5, CRAB_2_6_3_pre4, CRAB_2_6_3_pre3, CRAB_2_6_3_pre2, CRAB_2_7_0_pre2, CRAB_2_6_3_pre1, test_1, CRAB_2_7_0_pre1, CRAB_2_6_2, CRAB_2_6_2_pre2, CRAB_2_6_2_pre1, CRAB_2_6_1_pre4, CRAB_2_6_1_pre3, CRAB_2_6_1_pre2, CRAB_2_6_1_pre1, CRAB_2_6_1, CRAB_2_6_0, CRAB_2_6_0_pre14, CRAB_2_6_0_pre13, CRAB_2_6_0_pre12, CRAB_2_6_0_pre11, CRAB_2_6_0_pre10, CRAB_2_6_0_pre9, CRAB_2_6_0_pre8, CRAB_2_6_0_pre7, CRAB_2_6_0_pre6, CRAB_2_6_0_pre5, CRAB_2_6_0_pre4, CRAB_2_6_0_pre3, CRAB_2_6_0_pre2, CRAB_2_6_0_pre1, CRAB_2_5_1, CRAB_2_5_1_pre4, CRAB_2_5_1_pre3, CRAB_2_5_1_pre2, CRAB_2_5_1_pre1, CRAB_2_5_0, CRAB_2_5_0_pre7, CRAB_2_5_0_pre6, CRAB_2_5_0_pre5, CRAB_2_5_0_pre4, CRAB_2_5_0_pre3, CRAB_2_5_0_pre2, CRAB_2_5_0_pre1, CRAB_2_4_4, CRAB_2_4_4_pre6, CRAB_2_4_4_pre5, CRAB_2_4_4_pre4, CRAB_2_4_4_pre3, CRAB_2_4_4_pre2, CRAB_2_4_4_pre1, CRAB_2_4_3, CRAB_2_4_3_pre8, CRAB_2_4_3_pre7, CRAB_2_4_3_pre6, CRAB_2_4_3_pre5, CRAB_2_4_3_pre3, CRAB_2_4_3_pre2, CRAB_2_4_3_pre1, CRAB_2_4_2, CRAB_2_4_2_pre3, CRAB_2_4_2_pre2 |
Branch point for: | Lumi2_8, CRAB_2_6_X_br |
Changes since 1.6: | +6 -9 lines |
Log Message: | why using try: except: when a simple if would do? |
# | User | Rev | Content |
---|---|---|---|
1 | spiga | 1.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 | import popen2 | ||
12 | |||
13 | from ProdCommon.FwkJobRep.ReportParser import readJobReport | ||
14 | from ProdCommon.FwkJobRep.FwkJobReport import FwkJobReport | ||
15 | |||
16 | farinafa | 1.4 | from ProdCommon.FwkJobRep.PerformanceReport import PerformanceReport |
17 | |||
18 | spiga | 1.1 | class fjrParser: |
19 | def __init__(self, argv): | ||
20 | slacapra | 1.7 | if (len(argv))<2: |
21 | spiga | 1.1 | print "it is necessary to specify the fjr name" |
22 | sys.exit(2) | ||
23 | slacapra | 1.7 | self.reportFileName = argv[1] |
24 | self.directive = argv[2] | ||
25 | spiga | 1.1 | |
26 | farinafa | 1.2 | if self.directive=='--errorcode': |
27 | slacapra | 1.7 | self.wrapperExitCode = argv[3] |
28 | self.exeExitCode='' | ||
29 | if (len(argv))>4: self.exeExitCode = argv[4] | ||
30 | farinafa | 1.2 | |
31 | elif self.directive=='--timing': | ||
32 | self.wrapperTime = 'NULL' | ||
33 | self.exeTime = 'NULL' | ||
34 | self.stageoutTime = 'NULL' | ||
35 | farinafa | 1.4 | self.cpuTime = 'NULL' |
36 | farinafa | 1.2 | try: |
37 | self.wrapperTime = argv[3] | ||
38 | self.exeTime = argv[4] | ||
39 | self.stageoutTime = argv[5] | ||
40 | farinafa | 1.5 | # pay attenition that the input env var is actually a string of 3 attrutes # Fabio |
41 | self.cpuTime = "%s %s %s"%(argv[6], argv[7], argv[8]) | ||
42 | farinafa | 1.6 | self.cpuTime.replace('"','').replace('"','') |
43 | farinafa | 1.2 | except: |
44 | pass | ||
45 | else: | ||
46 | print "bad directive specified" | ||
47 | sys.exit(2) | ||
48 | spiga | 1.1 | return |
49 | |||
50 | def run(self): | ||
51 | |||
52 | if not os.path.exists(self.reportFileName): | ||
53 | self.writeFJR() | ||
54 | else: | ||
55 | self.fillFJR() | ||
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=open(self.reportFileName,'r') | ||
90 | lines = fjr.readlines() | ||
91 | if len(lines) > 0: valid = 1 | ||
92 | |||
93 | return valid | ||
94 | |||
95 | def fillFJR(self): | ||
96 | """ | ||
97 | """ | ||
98 | valid = self.checkValidFJR() | ||
99 | farinafa | 1.2 | if valid == 1 and self.directive=='--errorcode': |
100 | spiga | 1.1 | jobReport = readJobReport(self.reportFileName)[0] |
101 | if (len(jobReport.errors) > 0): | ||
102 | error = 0 | ||
103 | for err in jobReport.errors: | ||
104 | if err['Type'] == "WrapperExitCode" : | ||
105 | err['ExitStatus'] = self.wrapperExitCode | ||
106 | jobReport.write(self.reportFileName) | ||
107 | error = 1 | ||
108 | if (self.exeExitCode != ""): | ||
109 | if err['Type'] == "ExeExitCode" : | ||
110 | err['ExitStatus'] = self.exeExitCode | ||
111 | jobReport.write(self.reportFileName) | ||
112 | error = 1 | ||
113 | if (error == 0): | ||
114 | jobReport.addError(self.wrapperExitCode, "WrapperExitCode") | ||
115 | if (self.exeExitCode != ""): | ||
116 | jobReport.addError(self.exeExitCode, "ExeExitCode") | ||
117 | jobReport.write(self.reportFileName) | ||
118 | else: | ||
119 | jobReport.addError(self.wrapperExitCode, "WrapperExitCode") | ||
120 | if (self.exeExitCode != ""): | ||
121 | jobReport.addError(self.exeExitCode, "ExeExitCode") | ||
122 | jobReport.write(self.reportFileName) | ||
123 | farinafa | 1.2 | |
124 | elif valid == 1 and self.directive=='--timing': | ||
125 | farinafa | 1.4 | jobReport = readJobReport(self.reportFileName)[0] |
126 | farinafa | 1.2 | # add here timing settings |
127 | farinafa | 1.4 | perf = jobReport.performance |
128 | perf.addSummary("CrabTiming", WrapperTime = self.wrapperTime, ExeTime = self.exeTime,\ | ||
129 | StageoutTime = self.stageoutTime, CpuTime = self.cpuTime) | ||
130 | jobReport.write(self.reportFileName) | ||
131 | farinafa | 1.2 | pass |
132 | spiga | 1.1 | else: |
133 | self.writeFJR() | ||
134 | |||
135 | if __name__ == '__main__': | ||
136 | try: | ||
137 | FjrParser_ = fjrParser(sys.argv) | ||
138 | FjrParser_.run() | ||
139 | except: | ||
140 | pass | ||
141 |