1 |
from Actor import *
|
2 |
from crab_util import *
|
3 |
import common
|
4 |
import string, os
|
5 |
|
6 |
class PostMortem(Actor):
|
7 |
def __init__(self, cfg_params, nj_list):
|
8 |
self.cfg_params = cfg_params
|
9 |
self.nj_list = nj_list
|
10 |
self.all_jobs=common._db.nJobs('list')
|
11 |
|
12 |
self.fname_base = common.work_space.jobDir() + self.cfg_params['CRAB.jobtype'].upper() + '_'
|
13 |
|
14 |
return
|
15 |
|
16 |
def run(self):
|
17 |
"""
|
18 |
The main method of the class.
|
19 |
"""
|
20 |
common.logger.debug( "PostMortem::run() called")
|
21 |
|
22 |
self.collectLogging()
|
23 |
|
24 |
def collectOneLogging(self, id):
|
25 |
job=self.up_task.getJob(id)
|
26 |
if not job: #id not in self.all_jobs:
|
27 |
common.logger.info('Warning: job # ' + str(id) + ' does not exist! Not possible to ask for postMortem ')
|
28 |
return
|
29 |
elif job.runningJob['state'] == 'Created':
|
30 |
common.logger.info('Warning: job # ' + str(id) + ' just Created ! Not possible to ask for postMortem ')
|
31 |
else:
|
32 |
fname = self.fname_base + str(id) + '.LoggingInfo'
|
33 |
if os.path.exists(fname):
|
34 |
common.logger.info('Logging info for job ' + str(id) + ' already present in '+fname+'\nRemove it for update')
|
35 |
return
|
36 |
common.scheduler.loggingInfo(id,fname)
|
37 |
fl = open(fname, 'r')
|
38 |
out = "".join(fl.readlines())
|
39 |
fl.close()
|
40 |
reason = self.decodeLogging(out)
|
41 |
common.logger.info('Logging info for job '+ str(id) +' written to '+str(fname))
|
42 |
common.logger.info('Reason for job status is:\n\n'+str(reason)+'\n')
|
43 |
return
|
44 |
|
45 |
|
46 |
def collectLogging(self):
|
47 |
self.up_task = common._db.getTask( self.nj_list )
|
48 |
for id in self.nj_list:
|
49 |
self.collectOneLogging(id)
|
50 |
return
|
51 |
|
52 |
def decodeLogging(self, out):
|
53 |
"""
|
54 |
"""
|
55 |
return common.scheduler.decodeLogInfo(out)
|
56 |
|