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.13 by corvo, Mon Nov 20 18:47:51 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   from crab_util import *
3 < import EdgLoggingInfo
4 < import CondorGLoggingInfo
3 > #import EdgLoggingInfo
4 > #import CondorGLoggingInfo
5   import common
6   import string, os
7  
# Line 10 | Line 10 | class PostMortem(Actor):
10          self.cfg_params = cfg_params
11          self.nj_list = nj_list
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 <        
13 >        self.fname_base = common.work_space.jobDir() + self.cfg_params['CRAB.jobtype'].upper() + '_'
14 >
15          return
16      
17      def run(self):
# Line 24 | Line 20 | class PostMortem(Actor):
20          """
21          common.logger.debug(5, "PostMortem::run() called")
22  
23 <        for c, v in self.nj_list.iteritems():
24 <            id = int(c)
25 <            out = common.scheduler.loggingInfo(v)
26 <            job = common.job_list[id - 1]
27 <            jobnum_str = '%06d' % (id)
28 <            fname = common.work_space.jobDir() + '/' + self.cfg_params['CRAB.jobtype'].upper() + '_' + jobnum_str + '.loggingInfo'
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 <            jdl = open(fname, 'w')
33 <            for line in out: jdl.write(line)
34 <            jdl.close()
35 <
36 <            reason = ''
37 <            ## 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(id) +': '+reason+'\n      written to '+fname)
52 <            
53 <            # ML reporting
54 <            jobId = ''
55 <            if common.scheduler.boss_scheduler_name == 'condor_g':
56 <                jobId = str(id) + '_' + self.hash + '_' + v
57 <            else:
58 <                jobId = str(id) + '_' + v
59 <
60 <            params = {'taskId': self.cfg_params['taskId'], 'jobId':  jobId, \
61 <                      'sid': v,
62 <                      'PostMortemCategory': loggingInfo.getCategory(), \
63 <                      'PostMortemReason': loggingInfo.getReason()}
64 <            self.cfg_params['apmon'].sendToML(params)
65 <            pass
66 <
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