示例#1
0
def __demo():
    wsd_common.init()
    wsd_common.enable_debug()
    tsl = wsd_discovery__operations.get_devices()
    for a in tsl:
        print(a)
        try:
            (ti, hss) = wsd_get(a)
            print(ti)
            for b in hss:
                print(b)
        except TimeoutError:
            print("The target did not reply")
示例#2
0
def __demo_simple_listener():
    import wsd_discovery__operations
    import wsd_transfer__operations
    wsd_common.init()
    tsl = wsd_discovery__operations.get_devices()
    (ti, hss) = wsd_transfer__operations.wsd_get(list(tsl)[0])
    for b in hss:
        if "wscn:ScannerServiceType" in b.types:
            listen_addr = "http://192.168.1.109:6666/wsd"
            wsd_scanner_all_events_subscribe(b, listen_addr)
            (xxx, dest_token) = wsd_scan_available_event_subscribe(
                b, "PROVA_PYTHON", "python_client", listen_addr)
            if dest_token is not None:
                token_map["python_client"] = dest_token
                host_map["python_client"] = b
            break

    server = HTTPServerWithContext(('', 6666), RequestHandler, "context")
    wsd_globals.debug = True
    server.serve_forever()
示例#3
0
def __demo():
    import wsd_scan__events
    import wsd_transfer__operations
    import wsd_discovery__operations

    wsd_common.init()
    tsl = wsd_discovery__operations.get_devices()
    for a in tsl:
        res = wsd_transfer__operations.wsd_get(a)
        if res is not False:
            (ti, hss) = res
            for b in hss:
                if "wscn:ScannerServiceType" in b.types:
                    listen_addr = "http://192.168.1.109:6666/wsd"
                    h = wsd_scan__events.wsd_scanner_all_events_subscribe(
                        b, listen_addr,
                        datetime.now() + timedelta(days=2))
                    # wsd_renew(b, h)
                    print(wsd_get_status(b, h))
                    wsd_unsubscribe(b, h)
示例#4
0
def __demo():
    wsd_common.init()
    wsd_globals.debug = False
    tsl = wsd_discovery__operations.get_devices()
    for a in tsl:
        (ti, hss) = wsd_transfer__operations.wsd_get(a)
        for b in hss:
            if "wscn:ScannerServiceType" in b.types:
                (d, c, s, std_ticket) = wsd_get_scanner_elements(b)
                print(a)
                print(ti)
                print(b)
                print(d)
                print(c)
                print(s)
                print(std_ticket)
                # t.doc_params.input_src = "ADF"
                # t.doc_params.images_num = 0
                (valid, ticket) = wsd_validate_scan_ticket(b, std_ticket)
                if valid:
                    j = wsd_create_scan_job(b, ticket)
                    print(j)
                    (js, t, dp, dl) = wsd_get_job_elements(b, j)
                    print(js)
                    print(t)
                    print(dp)
                    print(dl)
                    jobs = wsd_get_active_jobs(b)
                    for i in jobs:
                        print(i)
                    jobs = wsd_get_job_history(b)
                    for i in jobs:
                        print(i)
                    o = 0
                    while o < ticket.doc_params.images_num:
                        imgnum, imglist = wsd_retrieve_image(b, j, "prova.bmp")
                        for i in imglist:
                            i.save("prova_%d.bmp" % o, "BMP")
                            o += 1
#!/usr/bin/env python3
# -*- encoding: utf-8 -*-

from PyWSD import wsd_common, \
    wsd_discovery__operations, \
    wsd_transfer__operations, \
    wsd_globals


def wsd_get_printer_elements(hosted_print_service):
    fields = {"FROM": wsd_globals.urn, "TO": hosted_print_service.ep_ref_addr}
    wsd_common.submit_request({hosted_print_service.ep_ref_addr},
                              "ws-print__get_printer_elements.xml", fields)


if __name__ == "__main__":
    wsd_common.init()
    tsl = wsd_discovery__operations.get_devices()
    for a in tsl:
        print(a)
        (ti, hss) = wsd_transfer__operations.wsd_get(a)
        for b in hss:
            if "wprt:PrinterServiceType" in b.types:
                print(b)
                debug = True
                wsd_get_printer_elements(b)