1 |
|
from Actor import * |
2 |
|
from crab_exceptions import * |
3 |
– |
from crab_logger import Logger |
3 |
|
import common |
4 |
|
import string |
5 |
+ |
from ServerCommunicator import ServerCommunicator |
6 |
+ |
from StatusServer import StatusServer |
7 |
+ |
|
8 |
+ |
class CleanerServer(Cleaner): |
9 |
|
|
7 |
– |
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 |
> |
# get updated status from server |
23 |
|
try: |
20 |
– |
from StatusServer import StatusServer |
24 |
|
stat = StatusServer(self.cfg_params) |
25 |
|
stat.resynchClientSide() |
26 |
|
except: |
27 |
|
pass |
28 |
+ |
|
29 |
+ |
# check whether the action is allowable |
30 |
+ |
Cleaner.check() |
31 |
|
|
32 |
< |
def run(self): |
33 |
< |
""" |
34 |
< |
remove all |
32 |
> |
# notify the server to clean the task |
33 |
> |
csCommunicator = ServerCommunicator(self.server_name, self.server_port, self.cfg_params) |
34 |
> |
taskuuid = str(common._db.queryTask('name')) |
35 |
> |
|
36 |
> |
try: |
37 |
> |
csCommunicator.cleanTask(taskuuid) |
38 |
> |
except Exception, e: |
39 |
> |
msg = "Client Server comunication failed about cleanJobs: task " + taskuuid |
40 |
> |
common.logger.debug( msg) |
41 |
> |
pass |
42 |
|
|
43 |
< |
if common.jobDB.nJobs()>0: |
44 |
< |
self.check() |
43 |
> |
# TODO remove these lines once the integration completed |
44 |
> |
msg='' |
45 |
> |
msg+='functionality not yet available for the server. Work in progres \n' |
46 |
> |
msg+='only local working directory will be removed' |
47 |
> |
common.logger.info(msg) |
48 |
> |
# TODO - end |
49 |
|
|
50 |
< |
countEnded = 0 |
34 |
< |
for nj in range(common.jobDB.nJobs()): |
35 |
< |
if common.jobDB.status(nj) in ['Y','K', 'A', 'C']: |
36 |
< |
countEnded += 1 |
37 |
< |
if countEnded == common.jobDB.nJobs(): |
38 |
< |
tempWorkSpace = common.work_space.topDir() |
39 |
< |
common.scheduler.clean() |
40 |
< |
common.work_space.delete() |
41 |
< |
print ( 'crab. directory '+tempWorkSpace+' removed' ) |
42 |
< |
else: |
43 |
< |
common.logger.message ( 'Impossible to remove: not all jobs are yet finished\n (you maight kill these jobs and then clean the task)') |
44 |
< |
""" |
45 |
< |
msg='' |
46 |
< |
msg+='functionality not yet available for the server. Work in progres \n' |
47 |
< |
msg+='only local worling directory will be removed' |
48 |
< |
#msg+='planned for CRAB_2_5_0' |
49 |
< |
common.logger.message(msg) |
50 |
> |
# remove local structures |
51 |
|
common.work_space.delete() |
52 |
|
print 'directory '+common.work_space.topDir()+' removed' |
53 |
+ |
return |
54 |
+ |
|