ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/CRAB/python/StatusServer.py
Revision: 1.50
Committed: Mon May 24 12:31:01 2010 UTC (14 years, 11 months ago) by farinafa
Content type: text/x-python
Branch: MAIN
CVS Tags: CRAB_2_7_3_beta1, CRAB_2_7_3_beta
Changes since 1.49: +1 -3 lines
Log Message:
Different encoding avoiding explicit padding for base64 issues. Check on cacheDir for TaskRegister

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    
12 mcinquil 1.42 from xml.parsers.expat import *
13    
14 spiga 1.35 import zlib
15    
16 farinafa 1.24 class StatusServer(Status):
17    
18     def __init__(self, *args):
19 spiga 1.38
20 spiga 1.36 Status.__init__(self, *args)
21 spiga 1.38
22     # init client server params...
23     CliServerParams(self)
24 farinafa 1.24
25 farinafa 1.27 return
26    
27 spiga 1.41 def query(self,display=True):
28 spiga 1.1
29 mcinquil 1.48 warning_msg = self.resynchClientSide()
30 spiga 1.31
31     upTask = common._db.getTask()
32 spiga 1.41 self.compute(upTask,display)
33 spiga 1.31
34 mcinquil 1.48 if warning_msg is not None:
35     common.logger.info(warning_msg)
36    
37 farinafa 1.27 def resynchClientSide(self):
38 spiga 1.31 """
39     get status from the server and
40     aling back data on client
41     """
42 farinafa 1.24 task = common._db.getTask()
43 mcinquil 1.42 self.task_unique_name = str(task['name'])
44 spiga 1.28
45 farinafa 1.24 # communicator allocation
46 spiga 1.38 csCommunicator = ServerCommunicator(self.server_name, self.server_port, self.cfg_params)
47 mcinquil 1.42 handledXML = csCommunicator.getStatus( self.task_unique_name )
48 farinafa 1.24 del csCommunicator
49    
50     # align back data and print
51 mcinquil 1.42 reportXML = None
52 farinafa 1.47 useFallback = False
53 mcinquil 1.48 warning_msg = None
54 farinafa 1.47
55 farinafa 1.34 try:
56 farinafa 1.50 reportXML = zlib.decompress( handledXML.decode('base64') )
57 spiga 1.35 except Exception, e:
58 mcinquil 1.48 warning_msg = "WARNING: Problem while decompressing fresh status from the server. Use HTTP fallback"
59     common.logger.debug(warning_msg)
60 farinafa 1.47 common.logger.debug( traceback.format_exc() )
61     useFallback = True
62    
63     try:
64     if useFallback:
65     import urllib
66     xmlStatusURL = 'http://%s:8888/visualog/'%self.server_name
67     xmlStatusURL += '?taskname=%s&logtype=Xmlstatus'%common._db.queryTask('name')
68     common.logger.debug("Accessing URL for status fallback: %s"%xmlStatusURL)
69     reportXML = ''.join(urllib.urlopen(xmlStatusURL).readlines())
70     except Exception, e:
71 farinafa 1.49 warning_msg = "WARNING: Unable to retrieve status from server. Please issue crab -status again"
72 mcinquil 1.48 common.logger.debug(warning_msg)
73 farinafa 1.47 common.logger.debug( str(e) )
74 spiga 1.45 common.logger.debug( traceback.format_exc() )
75 mcinquil 1.48 return warning_msg
76 spiga 1.35
77     try:
78 farinafa 1.49 xmlStatus = minidom.parseString(reportXML)
79     reportList = xmlStatus.getElementsByTagName('Job')
80 farinafa 1.34 common._db.deserXmlStatus(reportList)
81 farinafa 1.49 except Exception, e:
82     warning_msg = "WARNING: Unable to extract status from XML file. Please issue crab -status again"
83 mcinquil 1.48 common.logger.debug(warning_msg)
84 farinafa 1.49 common.logger.debug("DUMP STATUS XML: %s" str(reportXML))
85     common.logger.debug( str(e) )
86 farinafa 1.47 common.logger.debug( traceback.format_exc() )
87 mcinquil 1.48 return warning_msg
88 spiga 1.35
89 mcinquil 1.48 return warning_msg
90 mcinquil 1.2
91 mcinquil 1.42 def showWebMon(self):
92 spiga 1.43 msg = 'You can also check jobs status at: http://%s:8888/logginfo\n'%self.server_name
93     msg += '\t( Your task name is: %s )\n'%common._db.queryTask('name')
94 spiga 1.45 common.logger.debug(msg)
95     #common.logger.info("Web status at: http://%s:8888/visualog/?taskname=%s&logtype=Status\n"%(self.server_name,self.task_unique_name))