ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/CRAB/python/Cleaner.py
Revision: 1.4
Committed: Wed Sep 20 17:29:52 2006 UTC (18 years, 7 months ago) by slacapra
Content type: text/x-python
Branch: MAIN
Changes since 1.3: +1 -1 lines
Log Message:
BOSS4 + sub-file splitting + taskDB

File Contents

# User Rev Content
1 slacapra 1.1 from crab_exceptions import *
2     from crab_logger import Logger
3     from StatusBoss import StatusBoss
4     from Status import Status
5     import common
6     import string, os
7    
8     class Cleaner:
9 corvo 1.3 def __init__(self, boss, cfg_params):
10 slacapra 1.1 """
11     constructor
12     """
13     if (boss):
14 corvo 1.3 self.status = StatusBoss(cfg_params)
15 slacapra 1.1 else:
16     self.status = Status()
17    
18     def check(self):
19     """
20     Check whether no job is still running or not yet retrieved
21     """
22     submittedJobs=0
23     doneJobs=0
24    
25     self.status.compute() # compute the status
26    
27     ## SL: What a ugly interface (I use here). I should try a dictionary or something similar...
28 slacapra 1.4 (ToTjob,countCreated,countReady,countSche,countRun,countCleared,countAbort,countCancel,countDone) = self.status.status()
29 slacapra 1.1
30     JobsOnGrid = countRun+countSche+countReady # job still on the grid
31     if JobsOnGrid or countDone:
32     msg = "There are still "
33     if JobsOnGrid:
34     msg= msg+str(JobsOnGrid)+" jobs submitted. Kill them '-kill' before '-clean'"
35     if (JobsOnGrid and countDone):
36     msg = msg + "and \nalso"
37     if countDone:
38     msg= msg+str(countDone)+" jobs Done. Get their outputs '-getoutput' before '-clean'"
39     raise CrabException(msg)
40    
41     pass
42    
43     def clean(self):
44     """
45     remove all
46     """
47 slacapra 1.2 if common.jobDB.nJobs()>0:
48     self.check()
49    
50 slacapra 1.1 # here I should first purge boss DB if central
51     print 'directory '+common.work_space.topDir()+' removed'
52     common.logger.close()
53     common.work_space.delete()