ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/CRAB/python/Cleaner.py
Revision: 1.6
Committed: Wed Jan 17 18:17:58 2007 UTC (18 years, 3 months ago) by slacapra
Content type: text/x-python
Branch: MAIN
CVS Tags: CRAB_1_5_1_pre1, CRAB_1_5_0, CRAB_1_5_0_pre9, CRAB_1_5_0_pre8, CRAB_1_5_0_pre7, CRAB_1_5_0_pre6, CRAB_1_5_0_pre5, CRAB_1_5_0_pre4
Changes since 1.5: +1 -3 lines
Log Message:
many minor fixes reported by pychecker, mostly unsude import and unused variables

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