ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/CRAB/python/PostMortem.py
(Generate patch)

Comparing COMP/CRAB/python/PostMortem.py (file contents):
Revision 1.4 by gutsche, Fri Jun 16 01:42:09 2006 UTC vs.
Revision 1.25 by belforte, Fri Jan 18 15:43:54 2013 UTC

# Line 1 | Line 1
1   from Actor import *
2 < import EdgLoggingInfo
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, use_boss):
7 >    def __init__(self, cfg_params, nj_list):
8          self.cfg_params = cfg_params
9          self.nj_list = nj_list
10 <        self.flag_useboss = use_boss
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(5, "PostMortem::run() called")
20 >        common.logger.debug( "PostMortem::run() called")
21  
22 <        if len(self.nj_list)==0:
20 <            common.logger.debug(5, "No jobs to check")
21 <            return
22 >        self.collectLogging()
23  
24 <        # run a list-match on first job
25 <        for nj in self.nj_list:
26 <            #nj parte da 1 --> nj = internal_id di boss
27 <            if self.flag_useboss == 1 :
28 <                id = common.scheduler.boss_SID(nj)
29 <                #print "id = ", id
30 <            #else:
31 <            #    id = common.jobDB.jobId(nj)
32 <            out = common.scheduler.loggingInfo(id)
33 <            # job_list inizia a contare da zero
34 <            job = common.job_list[nj-1]
35 <            #print "job.jdlFilename()", job.jdlFilename()
36 <            jdl_fname = string.replace(job.jdlFilename(),'jdl','loggingInfo')
37 <            #print "jdl_fname = ", jdl_fname
38 <            if os.path.exists(jdl_fname):
39 <                common.logger.message('Logging info for job '+str(nj)+' already present in '+jdl_fname+' Remove it for update')
40 <                continue
41 <            jdl = open(jdl_fname, 'w')
42 <            for line in out: jdl.write(line)
43 <            jdl.close()
44 <
44 <            loggingInfo = EdgLoggingInfo.EdgLoggingInfo()
45 <
46 <            reason = loggingInfo.decodeReason(out)
47 <
48 <            common.logger.message('Logging info for job '+str(nj)+': '+reason+'\n      written to '+jdl_fname)
49 <            
50 <            # ML reporting
51 <            jobId = ''
52 <            if common.scheduler.boss_scheduler_name == 'condor_g':
53 <                # create hash of cfg file
54 <                hash = makeCksum(common.work_space.cfgFileName())
55 <                jobId = str(nj) + '_' + hash + '_' + id
56 <            else:
57 <                jobId = str(nj) + '_' + id
58 <
59 <            params = {'taskId': self.cfg_params['taskId'], 'jobId':  jobId, \
60 <                      'sid': id,
61 <                      'PostMortemCategory': loggingInfo.getCategory(), \
62 <                      'PostMortemReason': loggingInfo.getReason()}
63 <            self.cfg_params['apmon'].sendToML(params)
64 <            pass
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  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines