import sys import os if sys.platform=="darwin": import pyGlobus.ioc from AccessGrid.ServiceCapability import ServiceCapability from AccessGrid.AGNetworkService import AGNetworkService from AccessGrid.Platform.ProcessManager import ProcessManager from AccessGrid.Descriptions import StreamDescription from AccessGrid.NetworkLocation import MulticastNetworkLocation class DebugNetworkService(AGNetworkService): def __init__(self, name): AGNetworkService.__init__(self, name, 'Debug', '1.0') # Create capabilities inconfig = {"Debug": "0"} inCap = ServiceCapability(name, 'consumer', 'debug', inconfig) outconfig = {"Debug": "1"} outCap = ServiceCapability(name, 'producer', 'debug', outconfig) self.inCapabilities = [inCap.ToXML()] self.outCapabilities = [outCap.ToXML()] print '\nnetwork service soap interface started' # Start the soap interface interface = DebugNetworkServiceI(self) self.Start(self, interface) print self.url def StopTransform(self, streamList): # Stop debug service print 'transform stopped' def Transform(self, streamList): # Start debug service newStreams = [] print 'transform started' for s in streamList: # Create new stream description # Capability of new stream will be the # same as the out capabilities of the network # service cap = s.capability cap.xml = self.outCapabilities[0] # Create new stream description location = MulticastNetworkLocation("224.2.2.2", 8000) ns = StreamDescription("Debug Stream", location, cap) newStreams.append(ns) return newStreams from AccessGrid.hosting.SOAPInterface import SOAPInterface, SOAPIWrapper class DebugNetworkServiceI(SOAPInterface): """ Interface class for the debug network service """ def __init__(self,impl): SOAPInterface.__init__(self,impl) def _authorize(self, *args, **kw): # Authorize everybody. return 1 def Transform(self, sList): self.impl.Transform(sList) def StopTransform(self): self.impl.StopTransform() def Stop(self): self.impl.Stop() class DebugNetworkServiceIW(SOAPIWrapper): """ SOAP interface for the debug network service. """ def __init__(self,url): SOAPIWrapper.__init__(self,url) def Transform(self, sList): self.proxy.Transform(sList) def StopTransform(self): self.proxy.StopTransform() def Stop(self): self.proxy.Stop() if __name__ == "__main__": import sys debug = DebugNetworkService("Debug Service") # The service will automatically register with the venue # given on the command line url = debug.app.GetOption('venueUrl') if not url: print "Please enter venue url on the command line; --venueUrl " sys.exit() debug.StartSignalLoop()