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.1 by mcinquil, Tue Jul 17 17:56:09 2007 UTC vs.
Revision 1.9 by farinafa, Tue Aug 25 11:56:52 2009 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines