ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/CRAB/python/Cleaner.py
Revision: 1.1
Committed: Wed Dec 7 11:58:47 2005 UTC (19 years, 4 months ago) by slacapra
Content type: text/x-python
Branch: MAIN
Log Message:
many modification for -clean: including small re-structuring of Status class

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     def __init__(self, boss):
10     """
11     constructor
12     """
13     if (boss):
14     self.status = StatusBoss()
15     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     (ToTjob,countReady,countSche,countRun,countCleared,countAbort,countCancel,countDone) = self.status.status()
29    
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     self.check()
48     # here I should first purge boss DB if central
49     print 'directory '+common.work_space.topDir()+' removed'
50     common.logger.close()
51     common.work_space.delete()