1 |
from Actor import *
|
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 |
|
10 |
def __init__(self, cfg_params):
|
11 |
"""
|
12 |
constructor
|
13 |
"""
|
14 |
Cleaner.__init__(self, cfg_params)
|
15 |
self.cfg_params = cfg_params
|
16 |
|
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:
|
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 |
# 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 |
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 |
# remove local structures
|
55 |
common.work_space.delete()
|
56 |
print 'directory '+common.work_space.topDir()+' removed'
|
57 |
return
|
58 |
|