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.2 by spiga, Thu May 29 10:46:41 2008 UTC vs.
Revision 1.10 by farinafa, Wed Aug 26 12:57:22 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 > 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  
8 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
18 <        """
19 <        obj = StatusServer(self.cfg_params)
20 <        obj.run()
21 <
22 <        pass
19 >        # init client server params...
20 >        CliServerParams(self)
21 >        return
22  
23      def run(self):
24 <        """
25 <        remove all
24 >        # get updated status from server
25 >        try:
26 >            stat = StatusServer(self.cfg_params)
27 >            stat.resynchClientSide()
28 >        except:
29 >            pass
30 >        
31 >        # check whether the action is allowable
32 >        self.check()
33 >
34 >        # notify the server to clean the task
35 >        csCommunicator = ServerCommunicator(self.server_name, self.server_port, self.cfg_params)
36 >        taskuuid = str(common._db.queryTask('name'))
37 >
38 >        try:
39 >            csCommunicator.cleanTask(taskuuid)
40 >        except Exception, e:
41 >            msg = "Client Server comunication failed about cleanJobs: task \n" + taskuuid
42 >            msg += "Only local working directory will be removed."
43 >            common.logger.debug( msg)
44 >            pass
45 >
46 >        # TODO remove these lines once the integration completed
47 >        msg=''
48 >        msg+='functionality not yet available for the server. Work in progres \n'
49 >        msg+='only local working directory will be removed'
50 >        common.logger.info(msg)
51 >        # TODO - end
52 >
53 >        # remove local structures
54 >        common.work_space.delete()
55 >        print 'directory '+common.work_space.topDir()+' removed'
56 >        return
57  
28        if common.jobDB.nJobs()>0:
29            self.check()
30
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)')
42        """
43        msg=''  
44        msg+='functionality not yet available for the server. Work in progres \n'
45        msg+='planned for CRAB_2_2_3'
46        common.logger.message(msg)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines