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])
|