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.15 by mcinquil, Fri Dec 7 13:49:40 2007 UTC

# Line 1 | Line 1
1   from Actor import *
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 >        if common.scheduler.boss_scheduler_name == 'condor_g':
14 >            # create hash of cfg file
15 >            self.hash = makeCksum(common.work_space.cfgFileName())
16 >        else:
17 >            self.hash = ''
18 >        
19          return
20      
21      def run(self):
# Line 16 | Line 24 | class PostMortem(Actor):
24          """
25          common.logger.debug(5, "PostMortem::run() called")
26  
27 <        if len(self.nj_list)==0:
28 <            common.logger.debug(5, "No jobs to check")
29 <            return
30 <
31 <        # run a list-match on first job
32 <        for nj in self.nj_list:
33 <            #nj parte da 1 --> nj = internal_id di boss
34 <            if self.flag_useboss == 1 :
27 <                id = common.scheduler.boss_SID(nj)
28 <                #print "id = ", id
29 <            #else:
30 <            #    id = common.jobDB.jobId(nj)
31 <            out = common.scheduler.loggingInfo(id)
32 <            # job_list inizia a contare da zero
33 <            job = common.job_list[nj-1]
34 <            #print "job.jdlFilename()", job.jdlFilename()
35 <            jdl_fname = string.replace(job.jdlFilename(),'jdl','loggingInfo')
36 <            #print "jdl_fname = ", jdl_fname
37 <            if os.path.exists(jdl_fname):
38 <                common.logger.message('Logging info for job '+str(nj)+' already present in '+jdl_fname+' Remove it for update')
27 >        for c, v in self.nj_list.iteritems():
28 >            id = int(c)
29 >            out = common.scheduler.loggingInfo(v)
30 >            # job = common.job_list[id - 1]
31 >            jobnum_str = '%06d' % (id)
32 >            fname = common.work_space.jobDir() + '/' + self.cfg_params['CRAB.jobtype'].upper() + '_' + jobnum_str + '.loggingInfo'
33 >            if os.path.exists(fname):
34 >                common.logger.message('Logging info for job ' + str(id) + ' already present in '+fname+'\nRemove it for update')
35                  continue
36 <            jdl = open(jdl_fname, 'w')
36 >            jdl = open(fname, 'w')
37              for line in out: jdl.write(line)
38              jdl.close()
39  
40 <            loggingInfo = EdgLoggingInfo.EdgLoggingInfo()
41 <
42 <            reason = loggingInfo.decodeReason(out)
40 >            reason = ''
41 >            ## SL this if-elif is the negation of OO! Mus disappear ASAP
42 >            if common.scheduler.boss_scheduler_name == "edg" or common.scheduler.boss_scheduler_name == "glite" or common.scheduler.boss_scheduler_name == "glitecoll":
43 >                loggingInfo = EdgLoggingInfo.EdgLoggingInfo()
44 >                reason = loggingInfo.decodeReason(out)
45 >            elif common.scheduler.boss_scheduler_name == "condor_g" :
46 >                loggingInfo = CondorGLoggingInfo.CondorGLoggingInfo()
47 >                reason = loggingInfo.decodeReason(out)
48 >            else :
49 >                reason = out
50  
51 <            common.logger.message('Logging info for job '+str(nj)+': '+reason+'\n      written to '+jdl_fname)
51 >            common.logger.message('Logging info for job '+ str(id) +': '+str(reason)+'\n      written to '+str(fname) )
52              
53              # ML reporting
54              jobId = ''
55              if common.scheduler.boss_scheduler_name == 'condor_g':
56 <                # create hash of cfg file
54 <                hash = makeCksum(common.work_space.cfgFileName())
55 <                jobId = str(nj) + '_' + hash + '_' + id
56 >                jobId = str(id) + '_' + self.hash + '_' + v
57              else:
58 <                jobId = str(nj) + '_' + id
58 >                jobId = str(id) + '_' + v
59  
60              params = {'taskId': self.cfg_params['taskId'], 'jobId':  jobId, \
61 <                      'sid': id,
61 >                      'sid': v,
62                        'PostMortemCategory': loggingInfo.getCategory(), \
63                        'PostMortemReason': loggingInfo.getReason()}
64              self.cfg_params['apmon'].sendToML(params)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines