ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/CRAB/python/Cleaner.py
Revision: 1.10
Committed: Sat Apr 26 08:08:34 2008 UTC (17 years ago) by spiga
Content type: text/x-python
Branch: MAIN
CVS Tags: CRAB_2_2_0_pre13
Changes since 1.9: +2 -2 lines
Log Message:
use DBinterface for DB interaction

File Contents

# User Rev Content
1 slacapra 1.7 from Actor import *
2 slacapra 1.1 from crab_exceptions import *
3     from crab_logger import Logger
4     from Status import Status
5     import common
6 slacapra 1.6 import string
7 slacapra 1.1
8 slacapra 1.7 class Cleaner(Actor):
9 slacapra 1.5 def __init__(self, cfg_params):
10 slacapra 1.1 """
11     constructor
12     """
13 spiga 1.8 self.status = Status(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 spiga 1.10 countSub = len(common._db.queryAttrRunJob({'status':'S'},'status'))
23     countDone = len(common._db.queryAttrRunJob({'status':'SD'},'status'))
24 slacapra 1.1
25 slacapra 1.9 if countSub or countDone:
26 slacapra 1.1 msg = "There are still "
27 slacapra 1.9 if countSub:
28     msg= msg+str(countSub)+" jobs submitted. Kill them '-kill' before '-clean'"
29     if (countSub and countDone):
30 slacapra 1.1 msg = msg + "and \nalso"
31     if countDone:
32     msg= msg+str(countDone)+" jobs Done. Get their outputs '-getoutput' before '-clean'"
33     raise CrabException(msg)
34    
35     pass
36    
37 slacapra 1.7 def run(self):
38 slacapra 1.1 """
39     remove all
40     """
41 slacapra 1.9 if common._db.nJobs()>0:
42 slacapra 1.2 self.check()
43    
44 slacapra 1.1 # here I should first purge boss DB if central
45 slacapra 1.7 common.scheduler.clean()
46     common.work_space.delete()
47 slacapra 1.1 print 'directory '+common.work_space.topDir()+' removed'