1 |
from Actor import *
|
2 |
from crab_exceptions import *
|
3 |
import common
|
4 |
import string
|
5 |
|
6 |
class CleanerServer(Actor):
|
7 |
def __init__(self, cfg_params):
|
8 |
"""
|
9 |
constructor
|
10 |
"""
|
11 |
self.cfg_params = cfg_params
|
12 |
|
13 |
def check(self):
|
14 |
"""
|
15 |
Check whether no job is still running or not yet retrieved
|
16 |
"""
|
17 |
# get updated status from server
|
18 |
try:
|
19 |
from StatusServer import StatusServer
|
20 |
stat = StatusServer(self.cfg_params)
|
21 |
stat.resynchClientSide()
|
22 |
except:
|
23 |
pass
|
24 |
|
25 |
def run(self):
|
26 |
"""
|
27 |
remove all
|
28 |
|
29 |
if common.jobDB.nJobs()>0:
|
30 |
self.check()
|
31 |
|
32 |
countEnded = 0
|
33 |
for nj in range(common.jobDB.nJobs()):
|
34 |
if common.jobDB.status(nj) in ['Y','K', 'A', 'C']:
|
35 |
countEnded += 1
|
36 |
if countEnded == common.jobDB.nJobs():
|
37 |
tempWorkSpace = common.work_space.topDir()
|
38 |
common.scheduler.clean()
|
39 |
common.work_space.delete()
|
40 |
print ( 'crab. directory '+tempWorkSpace+' removed' )
|
41 |
else:
|
42 |
common.logger.info ( 'Impossible to remove: not all jobs are yet finished\n (you maight kill these jobs and then clean the task)')
|
43 |
"""
|
44 |
msg=''
|
45 |
msg+='functionality not yet available for the server. Work in progres \n'
|
46 |
msg+='only local worling directory will be removed'
|
47 |
#msg+='planned for CRAB_2_5_0'
|
48 |
common.logger.info(msg)
|
49 |
common.work_space.delete()
|
50 |
print 'directory '+common.work_space.topDir()+' removed'
|