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.5 by slacapra, Wed Sep 20 17:29:52 2006 UTC vs.
Revision 1.18 by spiga, Tue Apr 15 09:37:47 2008 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines