Exemplo n.º 1
0
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"
Exemplo n.º 2
0
    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
Exemplo n.º 3
0
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))
Exemplo n.º 4
0
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']
Exemplo n.º 5
0
# 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')
Exemplo n.º 6
0
 def __init__(self, wsdl):
     self.wsdl = wsdl
     self.service = ServiceProxy(wsdl=wsdl, force=True)