ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/CRAB/python/PostMortem.py
Revision: 1.25
Committed: Fri Jan 18 15:43:54 2013 UTC (12 years, 3 months ago) by belforte
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, HEAD
Changes since 1.24: +2 -1 lines
Log Message:
improve output formatting https://savannah.cern.ch/bugs/index.php?99796

File Contents

# Content
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