ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/CRAB/python/CondorGLoggingInfo.py
Revision: 1.2
Committed: Fri Oct 13 20:09:46 2006 UTC (18 years, 6 months ago) by gutsche
Content type: text/x-python
Branch: MAIN
CVS Tags: CRAB_1_5_0_pre3, CRAB_1_5_0_pre2, CRAB_1_4_2, CRAB_1_5_0_pre1, CRAB_1_4_1, CRAB_1_4_1_pre2, CRAB_1_4_1_pre1, CRAB_1_4_0, CRAB_1_4_0_pre4
Branch point for: branch_1_4_1
Changes since 1.1: +1 -0 lines
Log Message:
secure category parsing if HoldReason not included in condor_q -l

File Contents

# User Rev Content
1 gutsche 1.1 #!/usr/bin/env python
2    
3     import sys, os, string
4    
5     class CondorGLoggingInfo:
6     def __init__(self) :
7     self._categories = ['Grid error'
8     'Resource unavailable',
9     'Grid error before job started',
10     'Grid error after job started',
11     'Aborted by user',
12     'Application error',
13     'Success']
14     self.category = ''
15     self.reason = ''
16    
17     def parseFile(self,filename) :
18    
19     # open file
20     try:
21     file = open(filename)
22     except IOError:
23     print ''
24     print 'Could not open file: ',filename
25     return ''
26    
27     return self.decodeReason(file.readlines())
28    
29     def decodeReason(self, input) :
30     """
31     extract meaningful message from condor_q -l
32     """
33    
34 gutsche 1.2 msg = ''
35 gutsche 1.1 for line in input.splitlines() :
36     if line.find('HoldReason') != -1 :
37     msg = line.split('\"')[-2]
38     break
39    
40     if msg.find('authentication with the remote server failed') :
41     self.category = self._categories[2]
42     else :
43     self.category = self._categories[0]
44    
45     self.reason = msg
46    
47     return msg
48    
49     def getCategory(self) :
50     return self.category
51    
52     def getReason(self) :
53     return self.reason
54    
55    
56     if __name__ == '__main__' :
57    
58     info = CondorGLoggingInfo()
59     print info.parseFile(sys.argv[1])