2 |
|
from crab_exceptions import * |
3 |
|
import common |
4 |
|
import string |
5 |
+ |
from ServerCommunicator import ServerCommunicator |
6 |
+ |
from StatusServer import StatusServer |
7 |
+ |
|
8 |
+ |
class CleanerServer(Cleaner): |
9 |
|
|
6 |
– |
class CleanerServer(Actor): |
10 |
|
def __init__(self, cfg_params): |
11 |
|
""" |
12 |
|
constructor |
13 |
|
""" |
14 |
+ |
Cleaner.__init__(self, cfg_params) |
15 |
|
self.cfg_params = cfg_params |
16 |
|
|
17 |
< |
def check(self): |
18 |
< |
""" |
19 |
< |
Check whether no job is still running or not yet retrieved |
20 |
< |
""" |
21 |
< |
# get updated status from server |
17 |
> |
# init client server params... |
18 |
> |
CliServerParams(self) |
19 |
> |
return |
20 |
> |
|
21 |
> |
def run(self): |
22 |
> |
############## Temporary trick (till the right version get tested) #### |
23 |
> |
msg='' |
24 |
> |
msg+='functionality not yet available for the server. Work in progres \n' |
25 |
> |
msg+='only local worling directory will be removed' |
26 |
> |
#msg+='planned for CRAB_2_5_0' |
27 |
> |
common.logger.info(msg) |
28 |
> |
common.work_space.delete() |
29 |
> |
print 'directory '+common.work_space.topDir()+' removed' |
30 |
> |
return |
31 |
> |
|
32 |
> |
############## CliSer version #################### |
33 |
> |
# get updated status from server |
34 |
|
try: |
19 |
– |
from StatusServer import StatusServer |
35 |
|
stat = StatusServer(self.cfg_params) |
36 |
|
stat.resynchClientSide() |
37 |
|
except: |
38 |
|
pass |
39 |
+ |
|
40 |
+ |
# check whether the action is allowable |
41 |
+ |
Cleaner.check() |
42 |
|
|
43 |
< |
def run(self): |
44 |
< |
""" |
45 |
< |
remove all |
43 |
> |
# notify the server to clean the task |
44 |
> |
csCommunicator = ServerCommunicator(self.server_name, self.server_port, self.cfg_params) |
45 |
> |
taskuuid = str(common._db.queryTask('name')) |
46 |
|
|
47 |
< |
if common.jobDB.nJobs()>0: |
48 |
< |
self.check() |
47 |
> |
try: |
48 |
> |
csCommunicator.cleanTask(taskuuid) |
49 |
> |
except Exception, e: |
50 |
> |
msg = "Client Server comunication failed about cleanJobs: task " + taskuuid |
51 |
> |
common.logger.debug( msg) |
52 |
> |
pass |
53 |
|
|
54 |
< |
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) |
54 |
> |
# remove local structures |
55 |
|
common.work_space.delete() |
56 |
|
print 'directory '+common.work_space.topDir()+' removed' |
57 |
+ |
return |
58 |
+ |
|