def __init__(self, wsid, pw, url = "http://cas.sdss.org/CasJobs/services/jobs.asmx?WSDL", debug = False): if debug: ServiceProxy.__init__(self, url, tracefile=sys.stdout, force = True) else: ServiceProxy.__init__(self, url, force = True) # casjobs wsid and password for all methods self._wsid = wsid self._pw = pw self.types = self._get_job_types() self.queues = self._get_queues() self.jobstatus = {0 : "ready", 1 : "started", 2 : "canceling", 3 : "cancelled", 4 : "failed", 5 : "finished"} # Show warnings warnings.simplefilter('always')
def __init__(self, wsid, pw, url="http://cas.sdss.org/CasJobs/services/jobs.asmx?WSDL", debug=False): if debug: ServiceProxy.__init__(self, url, tracefile=sys.stdout, force=True) else: ServiceProxy.__init__(self, url, force=True) # casjobs wsid and password for all methods self._wsid = wsid self._pw = pw self.types = self._get_job_types() self.queues = self._get_queues() self.jobstatus = { 0: "ready", 1: "started", 2: "canceling", 3: "cancelled", 4: "failed", 5: "finished" } # Show warnings warnings.simplefilter('always')
def __init__(self, con_opts): wsdl_url = 'file://%s/PeakflowSP.wsdl' % os.path.dirname(__file__) soap_url = 'https://%s/soap/sp' % con_opts.host cred = (AUTH.httpdigest, con_opts.username, con_opts.password) self.soap = ServiceProxy(wsdl=wsdl_url, url=soap_url, auth=cred) self._timeout = 10
def send(alert): if not alert: return None server = ServiceProxy(wsdl='./wsdl/binding.wsdl') logging.debug("Sending " + str(alert)) one = 1 two = 2 response = server.add(One=one, Two=two) logging.info("Got response : " + str(response)) response = server.send(Date="", Sender="", Reference="", Host="", Message="", Priority=0) logging.info("Got response : " + str(response))
def send(alert): if not alert: return None server = ServiceProxy( wsdl='./wsdl/binding.wsdl') logging.debug("Sending "+str(alert)) one=1 two=2 response = server.add(One=one,Two=two) logging.info("Got response : "+ str( response)) response = server.send( Date = "", Sender = "", Reference = "", Host ="", Message = "", Priority = 0) logging.info("Got response : "+ str( response))
def run(options): global times text = "" if options.directory is None: with codecs.open(options.input_file, "r", "utf-8") as f: text = f.read() elif not options.directory.endswith("/"): options.directory += "/" service = ServiceProxy(wsdl=service_wsdl) times = [None] * options.num threads = [None] * options.num sum_time = 0 total_time = time.time() for i in range(0, options.num): if options.directory is not None: filename = options.directory + options.input_file.replace( "NN", str(i + 1)) with codecs.open(filename, "r", "utf-8") as f: text = f.read() threads[i] = Thread(target = process_request, \ args = (i, options, text, service)) threads[i].start() for i in range(0, options.num): threads[i].join() sum_time += times[i] total_time = time.time() - total_time print "Requests sent:", options.num #print "Successfully processed:", num_succesful #print "Times:", times print "Average time:", sum_time / options.num, "s" print "Total time:", total_time, "s" print "Time / request:", total_time / options.num, "s"
def __init__(self, con_opts): wsdl_url = 'file://%s/PeakflowSP.wsdl' % os.path.dirname(__file__) soap_url = 'https://%s/soap/sp' % con_opts.host cred = (AUTH.httpdigest, con_opts.username, con_opts.password) self.soap = ServiceProxy(wsdl = wsdl_url, url = soap_url, auth = cred) self._timeout = 10
class Liner2WsApi: def __init__(self, wsdl): self.wsdl = wsdl self.service = ServiceProxy(wsdl=wsdl, force=True) def _read_input(self, input_file): with codecs.open(input_file, "r", "utf-8") as f: return f.read() def _write_output(self, text, output_file): with codecs.open(output_file, "w+", "utf-8") as f: f.write(text) def analyse(self, text, input_format, output_format, model): r = self.service.Annotate(input_format=input_format, output_format=output_format, model=model, text=text) token = r['response']['msg'] step = 0.1 while int(r['response']['status']) not in (3, 4): time.sleep(step) r = self.service.GetResult(token=token) # print r status = int(r['response']['status']) if status == 3: result_text = r['response']['msg'] if not isinstance(result_text, unicode): result_text = unicode(result_text, "utf-8") return result_text elif status == 4: raise Exception("Server error:", r['response']['msg']) def analyseCcl(self, text): return self.analyse("ccl", "ccl", text) def analyseCclFile(self, input_file, output_file): text = self._read_input(input_file) text = self.analyseCcl(text) self._write_output(text, output_file)
class PeakflowZsi: """ Client library for talking to Arbor Peakflow SP using ZSI """ def __init__(self, con_opts): wsdl_url = 'file://%s/PeakflowSP.wsdl' % os.path.dirname(__file__) soap_url = 'https://%s/soap/sp' % con_opts.host cred = (AUTH.httpdigest, con_opts.username, con_opts.password) self.soap = ServiceProxy(wsdl=wsdl_url, url=soap_url, auth=cred) self._timeout = 10 def cliRun(self, command): """ Run a command """ return self.soap.cliRun(command=command, timeout=self._timeout) def getTrafficGraph(self, query, graph_configuration): return self.soap.getTrafficGraph( query=query, graph_configuration=graph_configuration) def runXmlQuery(self, query, output_format='xml'): return self.soap.runXmlQuery(query=query, output_format=output_format) def getDosAlertDetailsXML(self, alert_id): return self.soap.getDosAlertDetailsXML(alertID=alert_id) def getDosAlertGraph(self, alert_id, width, height): return self.soap.getDosAlertGraph(alertID=alert_id, width=width, height=height) def getMitigationSummariesXML(self, filter='', max_count=1000): return self.soap.getMitigationSummariesXML(filter=filter, max_count=max_count)
def run(options): text = read_input(options) service = ServiceProxy(wsdl=service_wsdl) r = service.Annotate(input_format=options.input_format.upper(), output_format=options.output_format.upper(), text=text) token = r['response']['msg'] step = 0.1 processing_time = 0 while int(r['response']['status']) not in (3, 4): time.sleep(step) processing_time += step r = service.GetResult(token=token) # print r status = int(r['response']['status']) if status == 3: result_text = r['response']['msg'] if not isinstance(result_text, unicode): # ??? result_text = unicode(result_text, "utf-8") write_output(result_text, processing_time, options) elif status == 4: print "Server error:", r['response']['msg']
class PeakflowZsi: """ Client library for talking to Arbor Peakflow SP using ZSI """ def __init__(self, con_opts): wsdl_url = 'file://%s/PeakflowSP.wsdl' % os.path.dirname(__file__) soap_url = 'https://%s/soap/sp' % con_opts.host cred = (AUTH.httpdigest, con_opts.username, con_opts.password) self.soap = ServiceProxy(wsdl = wsdl_url, url = soap_url, auth = cred) self._timeout = 10 def cliRun(self, command): """ Run a command """ return self.soap.cliRun(command = command, timeout = self._timeout) def getTrafficGraph(self, query, graph_configuration): return self.soap.getTrafficGraph(query = query, graph_configuration = graph_configuration) def runXmlQuery(self, query, output_format = 'xml'): return self.soap.runXmlQuery(query = query, output_format = output_format) def getDosAlertDetailsXML(self, alert_id): return self.soap.getDosAlertDetailsXML(alertID = alert_id) def getDosAlertGraph(self, alert_id, width, height): return self.soap.getDosAlertGraph(alertID = alert_id, width = width, height = height) def getMitigationSummariesXML(self, filter = '', max_count = 1000): return self.soap.getMitigationSummariesXML(filter = filter, max_count = max_count)
# Web Service client in Python using ZSI - "Classless struct didn't get dictionary" from ZSI.ServiceProxy import ServiceProxy service = ServiceProxy('test.wsdl') service.NewOperation(NewOperationRequest='test')
date_dict["dst"], ) return time.asctime(timeTuple) options, args = op.parse_args() if not options.url: op.print_help() sys.exit(1) else: # "Canonicalize" WSDL URL options.url = options.url.replace("?WSDL", "?wsdl") if not options.url.endswith("?wsdl"): options.url += "?wsdl" service = ServiceProxy(wsdl=options.url, tracefile=sys.stdout) print "\nAccessing service DateService..." while 1: offset = raw_input("Enter offset as int [0]: ") try: offset = str(offset) except ValueError: offset = "SE" import pprint pprint.pprint(service.__dict__) pprint.pprint(service.__doc__) currentResponse = service.GetCountryByCountryCode(CountryCode=offset) # We get back a dictionaray
date_dict["hour"], date_dict["minute"], date_dict["second"], date_dict["weekday"], date_dict["dayOfYear"], date_dict["dst"]) return time.asctime(timeTuple) options, args = op.parse_args() if not options.url: op.print_help() sys.exit(1) else: # "Canonicalize" WSDL URL options.url = options.url.replace("?WSDL", "?wsdl") if not options.url.endswith("?wsdl"): options.url += "?wsdl" service = ServiceProxy(wsdl=options.url, tracefile=sys.stdout) while 1: offset = raw_input("Enter offset as int [0]: ") try: offset = int(offset) except ValueError: offset = 0 currentResponse = service.getCurrentDate(input=options.input) # We get back a dictionaray print "currentResponse:", currentResponse # Manually fill the argument dict for demonstration purposes only somedayDict = { ’year’: currentResponse[’today’][’year’], ’month’: currentResponse[’today’][’month’],
def __init__(self, wsdl): self.wsdl = wsdl self.service = ServiceProxy(wsdl=wsdl, force=True)