Skip to main content

WS-Discovery implementation for python

Project description

Documentation Status

WS-Discovery in Python

This is WS-Discovery implementation for Python 3. It allows to both discover services and publish discoverable services. For Python 2 support, use the latest 1.x version of this package.

Extensive package documentation is available at ReadTheDocs.

Install from PyPI: pip install WSDiscovery.

Basic usage

A simple wsdiscover command-line client is provided for discovering WS-Discovery compliant devices and systems. Run wsdiscover --help for usage instructions.

Here's an example of how to use the package in your Python code. The following code first publishes a service and then discovers it:

    from wsdiscovery.discovery import ThreadedWSDiscovery as WSDiscovery
    from wsdiscovery.publishing import ThreadedWSPublishing as WSPublishing
    from wsdiscovery import QName, Scope

    # Define type, scope & address of service
    ttype1 = QName("http://www.onvif.org/ver10/device/wsdl", "Device")
    scope1 = Scope("onvif://www.onvif.org/Model")
    xAddr1 = "localhost:8080/abc"

    # Publish the service
    wsp = WSPublishing()
    wsp.start()
    wsp.publishService(types=[ttype1], scopes=[scope1], xAddrs=[xAddr1])

    # Discover it (along with any other service out there)
    wsd = WSDiscovery()
    wsd.start()
    services = wsd.searchServices()
    for service in services:
        print(service.getEPR() + ":" + service.getXAddrs()[0])
    wsd.stop()

Development notes

To fix a bug or develop this package, it is recommended to use a virtual environment and set up a development environment. For example:

$ python3 -m venv venv
$ . venv/bin/activate
(venv) $ pip3 install -e .

Then you can call wsdiscover and wspublish from within this virtual environment. Any code changes to the package will be available and testable immediately.

Development state

This is not 100% complete and correct WS-Discovery implementation. It doesn't verify data received from the network. It may crash, and might contain security holes. No guarantees - test it carefully for your use case.

Authors and maintaining

Original version created by L.A. Fernando.

Code was then forked and maintained by Andrei Kopats.

Python2 support fixes by Michael Leinartas.

Python3 port done by Pieter Jordaan.

Packaging, major refactoring & command-line clients and reStructuredText package documentation by Petri Savolainen.

See full list of contributors on the GitHub page.

Changelog

2.0.1 (unreleased)

  • Fix socket leaks in NetworkingThread

2.0.0 (2020-04-16)

  • decoupled threaded networking from ws-discovery implementation
  • refactored app-level discovery & publishing code into their own modules
  • refactored message construction, serialization & deserialization
  • added new wspublish command-line client to publish a service
  • added unicast discovery support to wsdiscovercommand-line client
  • collected all namespaces in one module
  • improved README example
  • good documentation in reStructuredText with Sphinx
  • removed Python 2 support code

1.1.2 (2019-01-01)

  • Refactoring & Python2 fixes
  • Introduce automated Travis testing

1.1.1 (2018-12-21)

  • Fix packaging

1.1.0 (2018-12-21)

  • Add a simple command-line client (petri)
  • Debugging support, including message capture (petri)
  • Fix breakage caused by refactoring (petri)
  • Simple tests (petri)

1.0.0 (2018-12-18)

  • Improved packaging (petri)
  • Modularize & refactor (petri)
  • Better Python2 support (mleinart)

0.2 (2017-05-19)

  • First release @pypi (petri)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

WSDiscovery-2.1.2.tar.gz (23.2 kB view details)

Uploaded Source

File details

Details for the file WSDiscovery-2.1.2.tar.gz.

File metadata

  • Download URL: WSDiscovery-2.1.2.tar.gz
  • Upload date:
  • Size: 23.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.1

File hashes

Hashes for WSDiscovery-2.1.2.tar.gz
Algorithm Hash digest
SHA256 ab816deff2db101be59830317e19b78a95e9146b2b0a747953345ae68d1d8b58
MD5 e6e45e6b91be3044f8b7db950a169d5d
BLAKE2b-256 6c81c3e596d7c043a8b557feccb7f675d9bc4dbbcf2efcf08f4d30872a3fe429

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page