1 |
mcinquil |
1.1 |
from Actor import *
|
2 |
|
|
from crab_exceptions import *
|
3 |
|
|
import common
|
4 |
|
|
import string
|
5 |
farinafa |
1.7 |
from ServerCommunicator import ServerCommunicator
|
6 |
|
|
from StatusServer import StatusServer
|
7 |
|
|
|
8 |
|
|
class CleanerServer(Cleaner):
|
9 |
mcinquil |
1.1 |
|
10 |
|
|
def __init__(self, cfg_params):
|
11 |
|
|
"""
|
12 |
|
|
constructor
|
13 |
|
|
"""
|
14 |
farinafa |
1.7 |
Cleaner.__init__(self, cfg_params)
|
15 |
mcinquil |
1.1 |
self.cfg_params = cfg_params
|
16 |
|
|
|
17 |
farinafa |
1.7 |
# init client server params...
|
18 |
|
|
CliServerParams(self)
|
19 |
|
|
return
|
20 |
|
|
|
21 |
|
|
def run(self):
|
22 |
|
|
# get updated status from server
|
23 |
spiga |
1.3 |
try:
|
24 |
|
|
stat = StatusServer(self.cfg_params)
|
25 |
|
|
stat.resynchClientSide()
|
26 |
|
|
except:
|
27 |
|
|
pass
|
28 |
farinafa |
1.7 |
|
29 |
|
|
# check whether the action is allowable
|
30 |
|
|
Cleaner.check()
|
31 |
mcinquil |
1.1 |
|
32 |
farinafa |
1.7 |
# 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 |
spiga |
1.2 |
|
36 |
farinafa |
1.7 |
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 |
mcinquil |
1.1 |
|
43 |
farinafa |
1.8 |
# 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 |
farinafa |
1.7 |
# remove local structures
|
51 |
slacapra |
1.4 |
common.work_space.delete()
|
52 |
|
|
print 'directory '+common.work_space.topDir()+' removed'
|
53 |
farinafa |
1.7 |
return
|
54 |
|
|
|