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.34 |
try:
|
51 |
farinafa |
1.39 |
handledXML += "="*( len(handledXML)%8 )
|
52 |
farinafa |
1.37 |
reportXML = zlib.decompress( base64.urlsafe_b64decode(handledXML) )
|
53 |
spiga |
1.35 |
except Exception, e:
|
54 |
spiga |
1.36 |
common.logger.debug(1,"WARNING: Problem while decompressing fresh status from the server.")
|
55 |
mcinquil |
1.42 |
common.logger.debug(2, str(e))
|
56 |
|
|
common.logger.debug(3, traceback.format_exc() )
|
57 |
spiga |
1.35 |
return
|
58 |
|
|
|
59 |
|
|
try:
|
60 |
farinafa |
1.37 |
reportList = minidom.parseString(reportXML).getElementsByTagName('Job')
|
61 |
farinafa |
1.34 |
common._db.deserXmlStatus(reportList)
|
62 |
mcinquil |
1.42 |
except ExpatError, experr:
|
63 |
|
|
common.logger.debug(1,"ERROR: %s"%str(experr))
|
64 |
|
|
common.logger.debug(2, str(experr))
|
65 |
|
|
common.logger.debug(3, traceback.format_exc() )
|
66 |
|
|
# raise CrabException(str(experr))
|
67 |
|
|
except TypeError, e:
|
68 |
spiga |
1.36 |
common.logger.debug(1,"WARNING: Problem while retrieving fresh status from the server.")
|
69 |
mcinquil |
1.42 |
common.logger.debug(2, str(e))
|
70 |
|
|
common.logger.debug(3, traceback.format_exc() )
|
71 |
farinafa |
1.34 |
return
|
72 |
spiga |
1.35 |
|
73 |
spiga |
1.31 |
return
|
74 |
mcinquil |
1.2 |
|
75 |
mcinquil |
1.42 |
def showWebMon(self):
|
76 |
spiga |
1.43 |
msg = 'You can also check jobs status at: http://%s:8888/logginfo\n'%self.server_name
|
77 |
|
|
msg += '\t( Your task name is: %s )\n'%common._db.queryTask('name')
|
78 |
|
|
common.logger.message(msg)
|
79 |
mcinquil |
1.42 |
#common.logger.message("Web status at: http://%s:8888/visualog/?taskname=%s&logtype=Status\n"%(self.server_name,self.task_unique_name))
|