def main(): port = int(sys.argv[1]) if issubclass(EchoServer, ServiceSOAPBinding): AsServer(port, (Service('test'),)) return #from ZSI.twisted.WSresource import WSResource #if issubclass(EchoServer, WSResource): from twisted.internet import reactor reactor.callWhenRunning(twisted_main, port) reactor.run()
WolframSearch Service """ class Service(WolframSearchService): def soap_WolframSearch(self, ps): rsp = WolframSearchService.soap_WolframSearch(self, ps) msg = self.request t1 = time.time() opts = msg.Options rsp.Result = result = rsp.new_Result() if opts.Query == 'Newton': result.TotalMatches = 1 result.Matches = match = result.new_Matches() item = match.new_Item() item.Title = "Fig Newtons" item.Score = 10 item.URL = 'http://www.nabiscoworld.com/newtons/' match.Item = [item] result.SearchTime = time.time() - t1 return rsp if __name__ == "__main__": port = int(sys.argv[1]) AsServer(port, (Service('test'), ))
apolloDB.setRunStatus(vizRunId,'queued','Visualization has been subitted to GAIA for processing') ### pick a port port = -1 print str(self.portDict) while port == -1: for p in self.portDict.keys(): if self.portDict[p] is False: self.portDict[p]=True port = p break t = Process(target=ApolloToGaia,args=(vizRunId,simulationRunId,simulationTitle, gaiaFileName,gaiaOutputFileName, gaiaStyleFileName,gaiaURL, statusFile,self.LogDict[forLogMoniker],port,self.portDict)) t.start() print "The client requests a visualization of the following runId: "\ + str(vizRunId) except Exception as e: apolloDB.setRunStatus(vizRunId,'failed',str(e)) self.LogDict[forLogMoniker].update('FAILED') print str(e) raise e return response; ##run a webserver on 8087 AsServer(port=visWS.configuration['local']['serverPort'], services=[GaiaWebService('gaia'), ])
apolloDB.setRunStatus(init_runId, "staging", "executing on the remote system") returnVal = conn._executeCommand( "cd {0}/{1}; chmod a+x batch_run.py; nohup ./batch_run.py >& out &" .format(conn._remoteDir, remoteScr)) self.logger.update("SVC_SUBMIT_JOB_SUCCESS", message="%s" % returnVal) conn._close() t = Thread(target=monitorBatchStatus, args=(init_runId, apolloDB)) t.start() except Exception as e: self.logger.update("SVC_SUBMIT_JOB_FAILED", message="%s" % str(e)) apolloDB.setRunStatus(init_runId, "failed", self.logger.pollStatus()[1]) response[1]._methodCallStatus._status = 'failed' response[1]._methodCallStatus._message = str(e) return response response[1]._methodCallStatus._status = 'staging' response[ 1]._methodCallStatus._message = 'runSimulation call completed successfully' return response #run a webserver AsServer(port=int(simWS.configuration['local']['port']), services=[ SimulatorWebService('pscsimu'), ])
#old stuff, pre 1.1 #response._runId = vc._visualizationOptions._runId #response._visualizerOutputResource.append(vrr); outputResource = self.factory.new_UrlOutputResource_Def() outputResource._description = "GAIA animation" outputResource._URL = "http://warhol-fred.psc.edu/GAIA/" + gaiaOutputFileName + ".ogg" response._visualizerResult._visualizerOutputResource.append( outputResource) return response def soap_getRunStatus(self, ps, **kw): response = VisualizerService.soap_getRunStatus(self, ps, **kw) print "The client requests the status of run " + self.request._runId currentStatus = self.LogDict[self.request._runId].pollStatus() currentType = self.LogDict[self.request._runId].pollStatusType() response._runStatus = self.factory.new_RunStatus() response._runStatus._status = currentType response._runStatus._message = str(currentStatus[0]) + ": " + str( currentStatus[1]) return response #run a webserver on 8087 AsServer(port=gaiaConf.port, services=[ GaiaWebService('gaia'), ])
for fileName, content in fileDict.items(): with open(tempDirName + "/" + fileName, "wb") as f: f.write("%s" % content) remoteScr = 'fred.tmp.%s' % str(randID) conn._mkdir(remoteScr) for fileName, content in fileDict.items(): conn.sendFile(tempDirName + "/" + fileName, remoteScr + "/" + fileName) ### we do not need temp directory anymore shutil.rmtree(tempDirName) returnVal = conn.submitJob(randID, idPrefix, idPrefix) #print returnVal ### parse the run ID response._runId = idPrefix + str(returnVal) ### Add this connection to the dictionary of connections connections[response._runId] = conn return response #run a webserver on 8087 AsServer(port=8094, services=[ SimulatorWebService('fred'), ])
def soap_getRunStatus(self, ps, **kw): response = VisualizerService.soap_getRunStatus(self, ps, **kw) print "The client requests the status of run " + self.request._runId statusFile = "/scratch/stbrown/" + self.request._runId + ".status" with open(statusFile, "rb") as f: status = f.readline() response._runStatus = self.factory.new_RunStatus() print "Checking File " + statusFile print "Got Status " + status if status == "Running": response._runStatus._status = "running" response._runStatus._message = "GAIA Webservice is creating the visualization" elif status == "GaiaFailed": response._runStatus._status = "failed" response._runStatus._message = "GAIA Server has returned a failed response" elif status == "Completed": response._runStatus._status = "completed" response._runStatus._message = "GAIA Webservice has finished creating the visualization" # response._runStatus = self.factory.new_RunStatus() # response._runStatus._status = "WAITING" # response._runStatus._message = "method not implemented" return response #run a webserver on 8087 AsServer(port=8088, services=[ GaiaWebService('gaia'), ])
request = ps.Parse(getRunStatusRequest.typecode) runId = request._runId response._runStatus = self.factory.new_RunStatus() response._runStatus._status = 'RUNNING' response._runStatus._message = 'the run is currently running' return response #this method runs an epidemic simulator def soap_run(self, ps, **kw): response = SimulatorService.soap_run(self, ps, **kw) request = ps.Parse(runRequest.typecode) print "received run request" #extract the epidemic model input object from the request cfg = request._simulatorConfiguration #example to get the number of time steps in the simulation #run_length = cfg._simulatorTimeSpecification._runLength '''ACME code here''' response._runId = "1" return response #logger = logging.getLogger(""); #logger.setLevel(0) #run a webserver on 8087 AsServer(port=8087, services=[ FredWebService('acme'), ])
#response._runId = vId._visualizerDeveloper + "_" + vId._visualizerName + "_" + vId._visualizerVersion + "_42" print "The client requests a visualization of the following runId: " + vc._visualizationOptions._runId print "The client requests a visualization of the following location: " + vc._visualizationOptions._location print "The client requests the following output format: " + vc._visualizationOptions._outputFormat vrr = self.factory.new_VisualizerOutputResource() vrr._description = "Description of the visualization" vrr._URL = "http://www.example.com/some_movie.mp4" response._runId = vc._visualizationOptions._runId response._visualizerOutputResource.append(vrr) return response def soap_getRunStatus(self, ps, **kw): response = VisualizerService.soap_getRunStatus(self, ps, **kw) print "The client requests the status of run " + self.request._runId response._runStatus = self.factory.new_RunStatus() response._runStatus._status = "WAITING" response._runStatus._message = "method not implemented" return response #run a webserver on 8087 AsServer(port=8087, services=[ SkeletonVisualizerWebService('visualizerservice'), ])
if doVacc: fredConn._sendFile(tempDirName + "/fred-vaccination-schedule_0.txt") ### we do not need temp directory anymore shutil.rmtree(tempDirName) print "Running FRED" sys.stdout.flush() #returnVal = fredConn._submitPBSJob(randID) returnVal = fredConn._submitJob(randID) print returnVal ### parse the run ID response._runId = idPrefix + str(returnVal) #ssh.close() #sftp.close() return response #logger = logging.getLogger(""); #logger.setLevel(0) #run a webserver on 8087 AsServer(port=8087, services=[ FredWebService('fred'), ])
from EchoWSAddr200403Server_services_server import EchoWSAddr200403Server as EchoServer from ZSI.schema import GTD """ EchoServer example service WSDL: ../../samples/Echo/Echo.wsdl """ EndpointReferenceType = GTD('http://schemas.xmlsoap.org/ws/2004/03/addressing','EndpointReferenceType') class WSAService(EchoServer): def wsa_Echo(self, ps, addr): response = EchoServer.wsa_Echo(self, ps, addr) response.EchoResult = self.request.EchoIn if isinstance(response.EchoResult, EndpointReferenceType): addr1 = response.EchoResult for a in addr.Any: if a not in addr1.ReferenceProperties.Any: raise RuntimeError, 'EPRs dont match' return response if __name__ == "__main__" : port = int(sys.argv[1]) AsServer(port, (WSAService('test'),))