ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/CRAB/python/StatusServer.py
Revision: 1.32
Committed: Tue Apr 15 16:55:00 2008 UTC (17 years ago) by spiga
Content type: text/x-python
Branch: MAIN
CVS Tags: CRAB_2_2_0_pre7
Changes since 1.31: +1 -1 lines
Log Message:
minor fix

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 spiga 1.31
30 spiga 1.32 self.xml = self.cfg_params.get("USER.xml_report",'')
31 farinafa 1.27 return
32    
33 farinafa 1.24 # all the behaviors are inherited from the direct status. Only some mimimal modifications
34     # are needed in order to extract data from status XML and to align back DB information
35     # Fabio
36    
37 spiga 1.31 def query(self):
38 farinafa 1.27 common.scheduler.checkProxy()
39 spiga 1.1
40 spiga 1.31 self.resynchClientSide()
41    
42     upTask = common._db.getTask()
43     self.compute(upTask)
44    
45 farinafa 1.27 def resynchClientSide(self):
46 spiga 1.31 """
47     get status from the server and
48     aling back data on client
49     """
50 farinafa 1.24 task = common._db.getTask()
51 spiga 1.28 # proxy management
52     self.proxy = None # common._db.queryTask('proxy')
53     if 'X509_USER_PROXY' in os.environ:
54     self.proxy = os.environ['X509_USER_PROXY']
55     else:
56     status, self.proxy = commands.getstatusoutput('ls /tmp/x509up_u`id -u`')
57     self.proxy = proxy.strip()
58    
59 farinafa 1.24 # communicator allocation
60 farinafa 1.27 csCommunicator = ServerCommunicator(self.server_name, self.server_port, self.cfg_params, self.proxy)
61 farinafa 1.24 reportXML = csCommunicator.getStatus( str(task['name']) )
62     del csCommunicator
63    
64     # align back data and print
65     reportList = minidom.parseString(reportXML).getElementsByTagName('Job')
66 spiga 1.31 common._db.deserXmlStatus(reportList)
67 spiga 1.1
68 spiga 1.31 return
69 mcinquil 1.2