ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/CRAB/python/StatusServer.py
Revision: 1.47
Committed: Wed Feb 24 11:12:34 2010 UTC (15 years, 2 months ago) by farinafa
Content type: text/x-python
Branch: MAIN
CVS Tags: fede_170310
Branch point for: CRAB_multiout
Changes since 1.46: +17 -3 lines
Log Message:
Fallback mechanism for problems with status XML retrieval from CommandManager. Rollback for problem with runningJob['submission'] alignment between ser/cli until I'll prepare a 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    
12 mcinquil 1.42 from xml.parsers.expat import *
13    
14 spiga 1.35 import zlib
15     import base64
16    
17 farinafa 1.24 class StatusServer(Status):
18    
19     def __init__(self, *args):
20 spiga 1.38
21 spiga 1.36 Status.__init__(self, *args)
22 spiga 1.38
23     # init client server params...
24     CliServerParams(self)
25 farinafa 1.24
26 farinafa 1.27 return
27    
28 spiga 1.41 def query(self,display=True):
29 spiga 1.1
30 spiga 1.31 self.resynchClientSide()
31    
32     upTask = common._db.getTask()
33 spiga 1.41 self.compute(upTask,display)
34 spiga 1.31
35 farinafa 1.27 def resynchClientSide(self):
36 spiga 1.31 """
37     get status from the server and
38     aling back data on client
39     """
40 farinafa 1.24 task = common._db.getTask()
41 mcinquil 1.42 self.task_unique_name = str(task['name'])
42 spiga 1.28
43 farinafa 1.24 # communicator allocation
44 spiga 1.38 csCommunicator = ServerCommunicator(self.server_name, self.server_port, self.cfg_params)
45 mcinquil 1.42 handledXML = csCommunicator.getStatus( self.task_unique_name )
46 farinafa 1.24 del csCommunicator
47    
48     # align back data and print
49 mcinquil 1.42 reportXML = None
50 farinafa 1.47 useFallback = False
51    
52 farinafa 1.34 try:
53 farinafa 1.39 handledXML += "="*( len(handledXML)%8 )
54 farinafa 1.37 reportXML = zlib.decompress( base64.urlsafe_b64decode(handledXML) )
55 spiga 1.35 except Exception, e:
56 farinafa 1.47 common.logger.debug("WARNING: Problem while decompressing fresh status from the server. Use HTTP fallback")
57     common.logger.debug( traceback.format_exc() )
58     useFallback = True
59    
60     try:
61     if useFallback:
62     import urllib
63     xmlStatusURL = 'http://%s:8888/visualog/'%self.server_name
64     xmlStatusURL += '?taskname=%s&logtype=Xmlstatus'%common._db.queryTask('name')
65     common.logger.debug("Accessing URL for status fallback: %s"%xmlStatusURL)
66     reportXML = ''.join(urllib.urlopen(xmlStatusURL).readlines())
67     except Exception, e:
68 mcinquil 1.46 common.logger.info("WARNING: The status cache is out of date. Please issue crab -status again")
69 farinafa 1.47 common.logger.debug("WARNING: Problem also with HTTP status fallback.")
70     common.logger.debug( str(e) )
71 spiga 1.45 common.logger.debug( traceback.format_exc() )
72 spiga 1.35 return
73    
74     try:
75 farinafa 1.37 reportList = minidom.parseString(reportXML).getElementsByTagName('Job')
76 farinafa 1.34 common._db.deserXmlStatus(reportList)
77 mcinquil 1.42 except ExpatError, experr:
78 mcinquil 1.46 common.logger.info("WARNING: The status cache is out of date. Please issue crab -status again")
79 spiga 1.45 common.logger.debug("ERROR: %s"%str(experr))
80     common.logger.debug( str(experr))
81     common.logger.debug( traceback.format_exc() )
82 mcinquil 1.42 # raise CrabException(str(experr))
83     except TypeError, e:
84 mcinquil 1.46 common.logger.info("WARNING: The status cache is out of date. Please issue crab -status again")
85 spiga 1.45 common.logger.debug("WARNING: Problem while retrieving fresh status from the server.")
86     common.logger.debug( str(e))
87 farinafa 1.47 common.logger.debug( traceback.format_exc() )
88 farinafa 1.34 return
89 spiga 1.35
90 spiga 1.31 return
91 mcinquil 1.2
92 mcinquil 1.42 def showWebMon(self):
93 spiga 1.43 msg = 'You can also check jobs status at: http://%s:8888/logginfo\n'%self.server_name
94     msg += '\t( Your task name is: %s )\n'%common._db.queryTask('name')
95 spiga 1.45 common.logger.debug(msg)
96     #common.logger.info("Web status at: http://%s:8888/visualog/?taskname=%s&logtype=Status\n"%(self.server_name,self.task_unique_name))