Package Ganga :: Package Lib :: Package MonitoringServices :: Package OutputServerMS :: Module OutputServerMS'
[hide private]
[frames] | no frames]

Source Code for Module Ganga.Lib.MonitoringServices.OutputServerMS.OutputServerMS'

 1  from Ganga.GPIDev.Adapters.IMonitoringService import IMonitoringService 
 2   
3 -class OutputServerMS(IMonitoringService):
4 """ A very simple debugging tool: in case of application failure, the stdout and stderr is sent back to the xmlrpm server on the client. This assumes that the stderr and stdout files are produced in CWD. Reliability of this mechanism depends on the network configuration (firewalls etc). Unless environment variable GANGA_OUTPUTSERVERMS_URL is defined, the server on local host on port 8182 is assumed. The variable GANGA_OUTPUTSERVERMS_URL should be of form: http://host.name:port. 5 """
6 - def __init__(self, job_info):
7 IMonitoringService.__init__(self,job_info)
8
9 - def stop(self,exitcode,*other):
10 if exitcode: 11 def send_file(name): 12 try: 13 import xmlrpclib 14 s = xmlrpclib.ServerProxy(self.job_info['server_url']) 15 s.send_output(self.job_info['jobid'],name,file(name,'r').read()) 16 except Exception,x: 17 import sys 18 print >> sys.stderr, 'OutputServerMS exception raised while sending "%s": %s'%(name,str(x)) 19 import traceback 20 traceback.print_exc()
21 22 send_file('stderr') 23 send_file('stdout')
24
25 - def getJobInfo(self):
26 import os 27 28 try: 29 URL = os.environ['GANGA_OUTPUTSERVERMS_URL'] 30 except KeyError: 31 from Ganga.Utility.util import hostname 32 import ganga_output_server 33 URL = 'http://%s:%d'%(hostname(),ganga_output_server.DEFAULT_PORT) 34 35 return {'jobid':self.job_info.getFQID('.'),'server_url': URL}
36
37 - def getSandboxModules(self):
38 import Ganga.Lib.MonitoringServices.OutputServerMS.OutputServerMS 39 40 return [Ganga, Ganga.Lib, Ganga.Lib.MonitoringServices, Ganga.Lib.MonitoringServices.OutputServerMS, Ganga.Lib.MonitoringServices.OutputServerMS.OutputServerMS] + IMonitoringService.getSandboxModules(self)
41