ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/CRAB/python/Cleaner.py
Revision: 1.12
Committed: Tue May 26 10:23:00 2009 UTC (15 years, 11 months ago) by spiga
Content type: text/x-python
Branch: MAIN
CVS Tags: CRAB_2_6_0_pre7, CRAB_2_6_0_pre6, CRAB_2_6_0_pre5, CRAB_2_6_0_pre4, CRAB_2_6_0_pre3
Changes since 1.11: +0 -1 lines
Log Message:
adapting code to logging usage. (crab_logger removed)

File Contents

# User Rev Content
1 slacapra 1.7 from Actor import *
2 slacapra 1.1 from crab_exceptions import *
3     from Status import Status
4     import common
5 slacapra 1.6 import string
6 slacapra 1.1
7 slacapra 1.7 class Cleaner(Actor):
8 slacapra 1.5 def __init__(self, cfg_params):
9 slacapra 1.1 """
10     constructor
11     """
12 spiga 1.8 self.status = Status(cfg_params)
13 slacapra 1.1
14     def check(self):
15     """
16     Check whether no job is still running or not yet retrieved
17     """
18    
19 fanzago 1.11 task = common._db.getTask()
20     upTask = common.scheduler.queryEverything(task['id'])
21     self.status.compute(upTask) # compute the status
22 slacapra 1.1
23 spiga 1.10 countSub = len(common._db.queryAttrRunJob({'status':'S'},'status'))
24     countDone = len(common._db.queryAttrRunJob({'status':'SD'},'status'))
25 slacapra 1.1
26 slacapra 1.9 if countSub or countDone:
27 slacapra 1.1 msg = "There are still "
28 slacapra 1.9 if countSub:
29     msg= msg+str(countSub)+" jobs submitted. Kill them '-kill' before '-clean'"
30     if (countSub and countDone):
31 slacapra 1.1 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 slacapra 1.7 def run(self):
39 slacapra 1.1 """
40     remove all
41     """
42 slacapra 1.9 if common._db.nJobs()>0:
43 slacapra 1.2 self.check()
44    
45 slacapra 1.1 # here I should first purge boss DB if central
46 fanzago 1.11 #common.scheduler.clean()
47 slacapra 1.7 common.work_space.delete()
48 slacapra 1.1 print 'directory '+common.work_space.topDir()+' removed'