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 |
> |
self.all_jobs=common._db.nJobs('list') |
13 |
> |
|
14 |
> |
self.fname_base = common.work_space.jobDir() + self.cfg_params['CRAB.jobtype'].upper() + '_' |
15 |
> |
|
16 |
|
return |
17 |
|
|
18 |
|
def run(self): |
21 |
|
""" |
22 |
|
common.logger.debug(5, "PostMortem::run() called") |
23 |
|
|
24 |
< |
if len(self.nj_list)==0: |
25 |
< |
common.logger.debug(5, "No jobs to check") |
20 |
< |
return |
21 |
< |
|
22 |
< |
# run a list-match on first job |
23 |
< |
for nj in self.nj_list: |
24 |
< |
#nj parte da 1 --> nj = internal_id di boss |
25 |
< |
if self.flag_useboss == 1 : |
26 |
< |
id = common.scheduler.boss_SID(nj) |
27 |
< |
#print "id = ", id |
28 |
< |
#else: |
29 |
< |
# id = common.jobDB.jobId(nj) |
30 |
< |
out = common.scheduler.loggingInfo(id) |
31 |
< |
# job_list inizia a contare da zero |
32 |
< |
job = common.job_list[nj-1] |
33 |
< |
#print "job.jdlFilename()", job.jdlFilename() |
34 |
< |
jdl_fname = string.replace(job.jdlFilename(),'jdl','loggingInfo') |
35 |
< |
#print "jdl_fname = ", jdl_fname |
36 |
< |
if os.path.exists(jdl_fname): |
37 |
< |
common.logger.message('Logging info for job '+str(nj)+' already present in '+jdl_fname+' Remove it for update') |
38 |
< |
continue |
39 |
< |
jdl = open(jdl_fname, 'w') |
40 |
< |
for line in out: jdl.write(line) |
41 |
< |
jdl.close() |
42 |
< |
common.logger.message('Logging info for job '+str(nj)+' written to '+jdl_fname) |
43 |
< |
|
44 |
< |
pass |
24 |
> |
self.collectLogging() |
25 |
> |
|
26 |
|
|
27 |
+ |
def collectLogging(self): |
28 |
+ |
self.up_task = common._db.getTask( self.nj_list ) |
29 |
+ |
for id in self.nj_list: |
30 |
+ |
job=self.up_task.getJob(id) |
31 |
+ |
if not job: #id not in self.all_jobs: |
32 |
+ |
common.logger.message('Warning: job # ' + str(id) + ' does not exist! Not possible to ask for postMortem ') |
33 |
+ |
continue |
34 |
+ |
elif job.runningJob['status'] == 'C': |
35 |
+ |
common.logger.message('Warning: job # ' + str(id) + ' just Created ! Not possible to ask for postMortem ') |
36 |
+ |
else: |
37 |
+ |
fname = self.fname_base + str(id) + '.LoggingInfo' |
38 |
+ |
if os.path.exists(fname): |
39 |
+ |
common.logger.message('Logging info for job ' + str(id) + ' already present in '+fname+'\nRemove it for update') |
40 |
+ |
continue |
41 |
+ |
common.scheduler.loggingInfo(id,fname) |
42 |
+ |
fl = open(fname, 'r') |
43 |
+ |
out = "".join(fl.readlines()) |
44 |
+ |
fl.close() |
45 |
+ |
reason = self.decodeLogging(out) |
46 |
+ |
common.logger.message('Logging info for job '+ str(id) +': '+str(reason)+'\n written to '+str(fname)+' \n' ) |
47 |
|
return |
48 |
+ |
|
49 |
+ |
def decodeLogging(self, out): |
50 |
+ |
""" |
51 |
+ |
""" |
52 |
+ |
return common.scheduler.decodeLogInfo(out) |
53 |
|
|