ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/CRAB/python/EdgLoggingInfo.py
Revision: 1.7
Committed: Tue May 26 10:23:00 2009 UTC (15 years, 11 months ago) by spiga
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, 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_6_6_pre6, CRAB_2_7_1_pre2, CRAB_2_6_6_pre5, CRAB_2_7_1_pre1, 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, HEAD
Branch point for: CRAB_multiout, CRAB_2_7_1_branch, Lumi2_8, CRAB_2_6_X_br
Changes since 1.6: +1 -1 lines
Log Message:
adapting code to logging usage. (crab_logger removed)

File Contents

# Content
1 #!/usr/bin/env python
2
3 import sys , re #DS
4 EXIT_CODE_RE = re.compile('^\s*-\s*[Ee]xit.[Cc]ode\s*=\s*(.*?)\s*$')
5
6 class EdgLoggingInfo:
7 def __init__(self) :
8 self._events = ['Running', 'Done', 'Abort']
9 self._errors = ['Maradona', 'Globus error',
10 'gridmanager error', 'CondorG',
11 'BrokerInfo', 'Cannot download',
12 'Cannot upload']
13 self._categories = ['Resource unavailable',
14 'Grid error before job started',
15 'Grid error after job started',
16 'Aborted by user',
17 'Application error',
18 'Success',
19 'Failure while executing job wrapper' ]
20 self.category = ''
21 self.reason = ''
22
23 def parse_reason(self,reason) :
24 error = reason
25 if reason.count('Cannot download') >= 1 :
26 error = 'Cannot download ... from ...'
27 if reason.count('cannot retrieve previous matches') >= 1 :
28 error = 'Harmless warning'
29 if reason.count('RetryCount') >= 1 :
30 error = 'Harmless warning'
31 if reason.count('There were some warnings') >= 1 :
32 error = 'Harmless warning'
33 return error;
34
35 def parseFile(self,filename) :
36
37 # open file
38 try:
39 file = open(filename)
40 except IOError:
41 common.logger.info('Could not open file: '+filename)
42 return ''
43
44 return self.decodeReason(file.readlines())
45
46 def decodeReason(self, input) :
47 """
48 extract meaningful message from edg-job-get-logging-info -v 2
49 """
50 # init final variables
51 final_done_code = 0
52 final_abort_msg = ''
53 final_done_msg = ''
54 final_category = ''
55 final_abort = 0
56 final_done = 0
57 final_running = 0
58
59 # init variable used in loop
60 event = ''
61 reason = ''
62 exit_code = ''
63
64 lines = input.split('\n')
65 for line in lines :
66 if line.count('Event:') >= 1 :
67 event = line.split(':')[1].strip()
68 if event == 'Abort' :
69 final_abort = 1
70 if event == 'Running' :
71 final_running = 1
72 if event == 'Done' :
73 final_done = 1
74 if line.count('Reason') >= 1 :
75 reason = self.parse_reason(line.split('=')[1].strip())
76 match = EXIT_CODE_RE.match(line) #DS
77 if match: #DS
78 exit_code = match.groups()[0] #DS
79 #if line.count('exit_code') >= 1 :
80 # exit_code = line.split('=')[1].strip()
81 # if line.count('time') >= 1 :
82 # time = line.split('=')[1].strip()
83 if ( line.count('---') >= 1 or line.count('***') >= 1 ) and event != '' :
84 if event in self._events :
85 if event == 'Done' :
86 final_done_code = int(exit_code)
87 if final_done_msg == '' :
88 final_done_msg = reason
89 if final_done_msg != reason :
90 final_done_msg += '. '+reason
91 elif event == 'Abort' :
92 final_abort_msg = reason
93
94 if final_abort_msg.count('Failure while executing job wrapper') >= 1 and \
95 ( final_running == 1 ) :
96 final_category = self._categories[6]
97
98 if final_abort_msg.count('no compatible resources') >= 1 :
99 final_category = self._categories[0]
100
101 if ( final_running == 0 ) and \
102 ( final_abort == 1 ) and \
103 ( final_abort_msg.count('no compatible resources') >= 1 ) :
104 final_category = self._categories[1]
105
106 if ( final_running == 0 ) :
107 for error in self._errors :
108 if final_done_msg.count(error) >= 1 :
109 final_category = self._categories[1]
110
111 if ( final_running == 1 ) and \
112 ( final_done_code != 0 ) and \
113 ( final_done == 0 ) :
114 final_category = self._categories[2]
115
116
117 if ( final_running == 1 ) and \
118 ( final_done_code != 0 ) :
119 for error in self._errors :
120 if final_done_msg.count(error) >= 1 :
121 final_category = self._categories[2]
122
123 if ( final_done == 1 ) and \
124 ( final_done_msg.count('Aborted by user') >= 1 ) :
125 final_category = self._categories[3]
126
127 if ( final_running == 1 ) and \
128 ( final_abort == 0 ) and \
129 ( final_done == 1 ) and \
130 ( final_done_code != 0 ) :
131 check = 0
132 for error in self._errors :
133 if final_done_msg.count(error) >= 1 :
134 check = 1
135 if check == 0 :
136 final_category = self._categories[4]
137
138 if ( final_running == 1 ) and \
139 ( final_abort == 0 ) and \
140 ( final_done_code == 0 ) and \
141 ( final_done_msg.count('Aborted by user') == 0 ) :
142 final_category = self._categories[5]
143
144 msg = ''
145 if final_category == self._categories[0] :
146 msg = 'aborted because: "'+self._categories[0]+'". Abort msg: "'+final_abort_msg+'".'
147 self.reason = final_abort_msg
148 self.category = self._categories[0]
149 elif final_category == self._categories[1] :
150 if final_done == 1 :
151 msg = 'aborted with "'+self._categories[1]+'". Abort msg: "'+final_done_msg+'".'
152 self.reason = final_done_msg
153 self.category = self._categories[1]
154 else :
155 msg = 'aborted with "'+self._categories[1]+'". Abort msg: "'+final_abort_msg+'".'
156 self.reason = final_abort_msg
157 self.category = self._categories[1]
158 elif final_category == self._categories[2] :
159 msg = 'aborted with "'+self._categories[2]+'". Abort msg: "'+final_done_msg+'".'
160 self.reason = final_done_msg
161 self.category = self._categories[2]
162 elif final_category == self._categories[3] :
163 msg = 'was "'+self._categories[3]+'".'
164 self.reason = self._categories[3]
165 self.category = self._categories[3]
166 elif final_category == self._categories[4] :
167 msg = 'finished correctly but failed with error code: ', final_done_code
168 self.reason = msg
169 self.category = self._categories[4]
170 elif final_category == self._categories[5] :
171 msg = 'succeeded'
172 self.reason = msg
173 self.category = self._categories[5]
174 elif final_category == self._categories[6] :
175 msg = 'aborted with msg "'+final_abort_msg+'".'
176 self.reason = msg
177 self.category = self._categories[5]
178
179 return msg
180
181 def getCategory(self) :
182 return self.category
183
184 def getReason(self) :
185 return self.reason
186
187
188 if __name__ == '__main__' :
189
190 info = EdgLoggingInfo()
191 print info.parseFile(sys.argv[1])