ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/CRAB/python/StatusServer.py
Revision: 1.26
Committed: Wed Apr 2 12:12:36 2008 UTC (17 years, 1 month ago) by farinafa
Content type: text/x-python
Branch: MAIN
CVS Tags: CRAB_2_2_0_pre4
Changes since 1.25: +6 -2 lines
Log Message:
Added controls for 'all' failed tasks

File Contents

# User Rev Content
1 spiga 1.1 from Actor import *
2     from crab_util import *
3     import common
4     from ApmonIf import ApmonIf
5     import time
6    
7 farinafa 1.24 import traceback
8     from xml.dom import minidom
9     from ServerCommunicator import ServerCommunicator
10     from Status import Status
11 farinafa 1.25 from ServerConfig import *
12 farinafa 1.24
13     class StatusServer(Status):
14    
15     def __init__(self, *args):
16     self.cfg_params = args[0]
17     self.server_name = None
18 farinafa 1.25 self.server_port = None
19     self.srvCfg = {}
20     try:
21     self.srvCfg = ServerConfig(self.cfg_params['CRAB.server_name']).config()
22 farinafa 1.24
23 farinafa 1.25 self.server_name = str(self.srvCfg['serverName'])
24     self.server_port = int(self.srvCfg['serverPort'])
25 spiga 1.3 except KeyError:
26 farinafa 1.24 msg = 'No server selected or port specified.'
27     msg = msg + 'Please specify a server in the crab cfg file'
28     raise CrabException(msg)
29 mcinquil 1.2
30 farinafa 1.24 # all the behaviors are inherited from the direct status. Only some mimimal modifications
31     # are needed in order to extract data from status XML and to align back DB information
32     # Fabio
33    
34     def compute(self):
35     # proxy management
36     proxy = None # common._db.queryTask('proxy')
37     if 'X509_USER_PROXY' in os.environ:
38     proxy = os.environ['X509_USER_PROXY']
39     else:
40     status, proxy = commands.getstatusoutput('ls /tmp/x509up_u`id -u`')
41     proxy = proxy.strip()
42     common.scheduler.checkProxy()
43 spiga 1.1
44 farinafa 1.24 task = common._db.getTask()
45 spiga 1.1
46 farinafa 1.24 # communicator allocation
47     common.logger.message("Checking the status of all jobs: please wait")
48     csCommunicator = ServerCommunicator(self.server_name, self.server_port, self.cfg_params, proxy)
49     reportXML = csCommunicator.getStatus( str(task['name']) )
50     del csCommunicator
51    
52     # align back data and print
53     reportList = minidom.parseString(reportXML).getElementsByTagName('Job')
54     toPrint=[]
55     for job in task.jobs:
56 farinafa 1.26 if not job.runningJob:
57     raise CrabException( "Missing running object for job %s"%str(job['id']) )
58    
59 farinafa 1.24 id = str(job.runningJob['id'])
60 farinafa 1.25 # TODO linear search, probably it can be optized with binary search
61 farinafa 1.24 rForJ = None
62     for r in reportList:
63 farinafa 1.26 if r.getAttribute('id') in [ id, 'all']:
64 farinafa 1.24 rForJ = r
65     break
66    
67     # Data alignment
68     job.runningJob['statusScheduler'] = str( rForJ.getAttribute('status') )
69     jobStatus = str(job.runningJob['statusScheduler'])
70    
71     job.runningJob['destination'] = str( rForJ.getAttribute('site') )
72     dest = str(job.runningJob['destination']).split(':')[0]
73    
74     job.runningJob['applicationReturnCode'] = str( rForJ.getAttribute('exe_exit') )
75     exe_exit_code = str(job.runningJob['applicationReturnCode'])
76    
77     job.runningJob['wrapperReturnCode'] = str( rForJ.getAttribute('job_exit') )
78     job_exit_code = str(job.runningJob['wrapperReturnCode'])
79    
80 farinafa 1.26 if str( rForJ.getAttribute('resubmit') ).isdigit():
81     job['submissionNumber'] = int(rForJ.getAttribute('resubmit'))
82 farinafa 1.24 # TODO cleared='0' field, how should it be handled/mapped in BL? #Fabio
83     common.bossSession.updateDB( task )
84    
85     printline=''
86     if dest == 'None' : dest = ''
87     if exe_exit_code == 'None' : exe_exit_code = ''
88     if job_exit_code == 'None' : job_exit_code = ''
89     printline+="%-8s %-18s %-40s %-13s %-15s" % (id,jobStatus,dest,exe_exit_code,job_exit_code)
90     toPrint.append(printline)
91 spiga 1.1
92 farinafa 1.24 self.detailedReport(toPrint)
93     pass
94 spiga 1.1
95 mcinquil 1.2
96 farinafa 1.9
97 spiga 1.1