ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/CRAB/python/fillCrabFjr.py
Revision: 1.8
Committed: Sat Dec 12 15:36:14 2009 UTC (15 years, 4 months ago) by spiga
Content type: text/x-python
Branch: MAIN
CVS Tags: CRAB_2_8_2_pre1, CRAB_2_8_1, CRAB_2_8_0, CRAB_2_8_0_pre1, CRAB_2_7_10_pre3, CRAB_2_7_9_patch2_pre1, CRAB_2_7_10_pre2, CRAB_2_7_10_pre1, CRAB_2_7_9_patch1, CRAB_2_7_9, CRAB_2_7_9_pre5, CRAB_2_7_9_pre4, CRAB_2_7_9_pre3, CRAB_2_7_9_pre2, CRAB_2_7_8_patch2, CRAB_2_7_9_pre1, CRAB_2_7_8_patch2_pre1, CRAB_2_7_8_patch1, CRAB_2_7_8_patch1_pre1, CRAB_2_7_8, CRAB_2_7_8_pre3, CRAB_2_7_8_pre2, CRAB_2_7_8_dash3, CRAB_2_7_8_dash2, CRAB_2_7_8_dash, CRAB_2_7_7_patch1, CRAB_2_7_7_patch1_pre1, CRAB_2_7_8_pre1, CRAB_2_7_7, CRAB_2_7_7_pre2, CRAB_2_7_7_pre1, CRAB_2_7_6_patch1, CRAB_2_7_6, CRAB_2_7_6_pre1, CRAB_2_7_5_patch1, CRAB_2_7_5, CRAB_2_7_5_pre3, CRAB_2_7_5_pre2, CRAB_2_7_5_pre1, CRAB_2_7_4_patch1, CRAB_2_7_4, CRAB_2_7_4_pre6, CRAB_2_7_4_pre5, CRAB_2_7_4_pre4, CRAB_2_7_4_pre3, CRAB_2_7_4_pre2, CRAB_2_7_4_pre1, CRAB_2_7_3, CRAB_2_7_3_pre3, CRAB_2_7_3_pre3_beta, CRAB_2_7_3_pre2, CRAB_2_7_3_pre2_beta, CRAB_2_7_3_pre1, CRAB_2_7_3_beta3, CRAB_2_7_3_beta2, CRAB_2_7_3_beta1, CRAB_2_7_3_beta, CRAB_2_7_2_p1, CRAB_2_7_1_branch_firstMERGE, CRAB_2_7_2, CRAB_2_7_2_pre4, CRAB_2_7_2_pre3, CRAB_2_7_2_pre2, CRAB_2_7_2_pre1, CRAB_2_7_1, fede_170310, CRAB_2_7_1_pre12, CRAB_2_7_1_pre11, CRAB_2_7_1_pre10, CRAB_2_7_1_pre9, CRAB_LumiMask, CRAB_2_7_lumi, from_LimiMask, CRAB_2_7_1_pre8, CRAB_2_7_1_pre6, CRAB_2_7_1_pre5, CRAB_2_7_1_wmbs_pre4, CRAB_2_7_1_pre4, CRAB_2_7_1_pre3, CRAB_2_7_1_pre2, CRAB_2_7_1_pre1
Branch point for: CRAB_multiout, CRAB_2_7_1_branch
Changes since 1.7: +0 -1 lines
Log Message:
update to python2.6 (popen)

File Contents

# 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    
12     from ProdCommon.FwkJobRep.ReportParser import readJobReport
13     from ProdCommon.FwkJobRep.FwkJobReport import FwkJobReport
14    
15 farinafa 1.4 from ProdCommon.FwkJobRep.PerformanceReport import PerformanceReport
16    
17 spiga 1.1 class fjrParser:
18     def __init__(self, argv):
19 slacapra 1.7 if (len(argv))<2:
20 spiga 1.1 print "it is necessary to specify the fjr name"
21     sys.exit(2)
22 slacapra 1.7 self.reportFileName = argv[1]
23     self.directive = argv[2]
24 spiga 1.1
25 farinafa 1.2 if self.directive=='--errorcode':
26 slacapra 1.7 self.wrapperExitCode = argv[3]
27     self.exeExitCode=''
28     if (len(argv))>4: self.exeExitCode = argv[4]
29 farinafa 1.2
30     elif self.directive=='--timing':
31     self.wrapperTime = 'NULL'
32     self.exeTime = 'NULL'
33     self.stageoutTime = 'NULL'
34 farinafa 1.4 self.cpuTime = 'NULL'
35 farinafa 1.2 try:
36     self.wrapperTime = argv[3]
37     self.exeTime = argv[4]
38     self.stageoutTime = argv[5]
39 farinafa 1.5 # 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 farinafa 1.6 self.cpuTime.replace('"','').replace('&quot;','')
42 farinafa 1.2 except:
43     pass
44     else:
45     print "bad directive specified"
46     sys.exit(2)
47 spiga 1.1 return
48    
49     def run(self):
50    
51     if not os.path.exists(self.reportFileName):
52     self.writeFJR()
53     else:
54     self.fillFJR()
55     self.setStatus()
56    
57     return
58    
59     def setStatus(self):
60     """
61     """
62     if (self.wrapperExitCode == '0') and (self.exeExitCode == '0'):
63     status = 'Success'
64     else:
65     status = 'Failed'
66    
67     jobReport = readJobReport(self.reportFileName)[0]
68     jobReport.status = status
69     jobReport.write(self.reportFileName)
70    
71     return
72    
73     def writeFJR(self):
74     """
75     """
76     fwjr = FwkJobReport()
77     fwjr.addError(self.wrapperExitCode, "WrapperExitCode")
78     if (self.exeExitCode != ""):
79     fwjr.addError(self.exeExitCode, "ExeExitCode")
80     fwjr.write(self.reportFileName)
81    
82     return
83    
84     def checkValidFJR(self):
85     """
86     """
87     valid = 0
88     fjr=open(self.reportFileName,'r')
89     lines = fjr.readlines()
90     if len(lines) > 0: valid = 1
91    
92     return valid
93    
94     def fillFJR(self):
95     """
96     """
97     valid = self.checkValidFJR()
98 farinafa 1.2 if valid == 1 and self.directive=='--errorcode':
99 spiga 1.1 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 farinafa 1.2
123     elif valid == 1 and self.directive=='--timing':
124 farinafa 1.4 jobReport = readJobReport(self.reportFileName)[0]
125 farinafa 1.2 # add here timing settings
126 farinafa 1.4 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 farinafa 1.2 pass
131 spiga 1.1 else:
132     self.writeFJR()
133    
134     if __name__ == '__main__':
135     try:
136     FjrParser_ = fjrParser(sys.argv)
137     FjrParser_.run()
138     except:
139     pass
140