ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/CRAB/python/CleanerServer.py
(Generate patch)

Comparing COMP/CRAB/python/CleanerServer.py (file contents):
Revision 1.5 by slacapra, Tue Apr 28 16:18:31 2009 UTC vs.
Revision 1.11 by mcinquil, Wed Apr 28 15:15:28 2010 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines