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

Comparing COMP/CRAB/python/Resubmitter.py (file contents):
Revision 1.1 by slacapra, Wed Feb 13 18:17:53 2008 UTC vs.
Revision 1.12 by spiga, Tue May 26 10:23:01 2009 UTC

# Line 1 | Line 1
1   from Submitter import Submitter
2   import common
3   from crab_util import *
4 + from crab_exceptions import *
5  
6   class Resubmitter(Submitter):
7 <    def __init__(self, cfg_params, jobs, UseServer=0):
7 >    def __init__(self, cfg_params, jobs):
8 >        self.cfg_params = cfg_params
9 >
10          nj_list = []
8        for nj in jobs:
9            st = common.jobDB.status(int(nj)-1)
10            if st in ['K','A']:
11                nj_list.append(int(nj)-1)
12                common.jobDB.setStatus(int(nj)-1,'C')
13            elif st == 'Y':
14                common.scheduler.moveOutput(nj)
15                nj_list.append(int(nj)-1)
16                st = common.jobDB.setStatus(int(nj)-1,'RC')
17            elif st in ['C','X']:
18                common.logger.message('Job #'+`int(nj)`+' has status '+crabJobStatusToString(st)+' not yet submitted!!!')
19                pass
20            elif st == 'D':
21                common.logger.message('Job #'+`int(nj)`+' has status '+crabJobStatusToString(st)+' must be retrieved before resubmission')
22            else:
23                common.logger.message('Job #'+`nj`+' has status '+crabJobStatusToString(st)+' must be "killed" before resubmission')
24                pass
11  
12 +        nj_list = self.checkAlowedJob(jobs,nj_list)
13  
27        if len(nj_list) != 0:
28            nj_list.sort()
14  
15 <            # remove job ids from the submission history file (for the server) # Fabio
31 <            if (UseServer == 1):
32 <                file = open(common.work_space.shareDir()+'/submit_directive','r')
33 <                prev_subms = str(file.readlines()[0]).split('\n')[0]
34 <                file.close()
35 <
36 <                new_subms = []
37 <                if prev_subms != 'all':
38 <                    # remove the jobs in nj_list from the history
39 <                    new_subms = [ j for j in eval(prev_subms) not in nj_list ]
40 <
41 <                file = open(common.work_space.shareDir()+'/submit_directive','w')
42 <                file.write(str(new_subms))
43 <                file.close()
44 <            pass
45 <        pass
15 >        common.logger.info('Jobs '+str(nj_list)+' will be resubmitted')
16          Submitter.__init__(self, cfg_params, nj_list, 'range')
17 <        pass
17 >
18 >        return
19 >
20 >    def checkAlowedJob(self,jobs,nj_list):
21 >        listRunField=[]
22 >
23 >        task=common._db.getTask(jobs)
24 >        for job in task.jobs:
25 >            st = job.runningJob['status']
26 >            nj = job['jobId']
27 >            if st in ['K','A','SE','E','UE','DA','NS']:
28 >                nj_list.append(int(nj))
29 >            elif st == 'C':
30 >                common.logger.info('Job #'+`int(nj)`+' has status '+str(job.runningJob['statusScheduler'])+' not yet submitted!!!')
31 >            elif st in ['SD','D']:
32 >                common.logger.info('Job #'+`int(nj)`+' has status '+str(job.runningJob['statusScheduler'])+' must be retrieved before resubmission')
33 >            else:
34 >                common.logger.info('Job #'+`nj`+' has status '+str(job.runningJob['statusScheduler'])+' must be "killed" before resubmission')
35 >
36 >        if len(nj_list) == 0 :
37 >            msg='No jobs to resubmit'
38 >            raise CrabException(msg)
39 >        self.manageNewRunJobs(nj_list)
40 >        return nj_list
41 >
42 >    def manageNewRunJobs(self,nj_list):
43 >        """
44 >        Get new running instances
45 >        """
46 >        common._db.newRunJobs(nj_list)
47 >        return

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines