ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/CRAB/python/Submitter.py
Revision: 1.2
Committed: Tue Jun 21 11:06:51 2005 UTC (19 years, 10 months ago) by nsmirnov
Content type: text/x-python
Branch: MAIN
Changes since 1.1: +40 -2 lines
Log Message:
Job submission implemented

File Contents

# User Rev Content
1 nsmirnov 1.1 from Actor import *
2 nsmirnov 1.2 import common
3 nsmirnov 1.1
4     class Submitter(Actor):
5     def __init__(self, cfg_params, nsjobs):
6     self.cfg_params = cfg_params
7 nsmirnov 1.2 self.nsjobs = nsjobs
8 nsmirnov 1.1 return
9    
10     def run(self):
11 nsmirnov 1.2 """
12     The main method of the class.
13     """
14    
15     common.logger.debug(5, "Submitter::run() called")
16    
17     total_njobs = len(common.job_list)
18     if total_njobs == 0 :
19     msg = '\nTotal of 0 jobs submitted -- no created jobs found.\n'
20     msg += "Maybe you forgot '-create' or '-continue' ?\n"
21     common.logger.message(msg)
22     return
23    
24     # Loop over jobs
25    
26     njs = 0
27     for nj in range(total_njobs):
28     if njs == self.nsjobs : break
29     st = common.jobDB.status(nj)
30     if st != 'C': continue
31    
32     common.logger.debug(6, "Submitter::run(): job # "+`nj`)
33    
34     jid = common.scheduler.submit(nj)
35    
36     common.jobDB.setStatus(nj, 'S')
37     common.jobDB.setJobId(nj, jid)
38     njs = njs + 1
39     pass
40    
41     ####
42    
43     common.jobDB.save()
44    
45     msg = '\nTotal of %d jobs submitted'%njs
46     if njs != self.nsjobs: msg = msg + ' from %d requested'%self.nsjobs
47     msg = msg + '.\n'
48     common.logger.message(msg)
49 nsmirnov 1.1 return
50