Python implementation of a W3C WoT Runtime and the WoT Scripting API
Project description
:warning: Please note that this project is currently behind the current version of the W3C WoT specifications. Our intention is to get it up to speed and implement the latest Thing Description and Scripting API versions. However, we cannot provide a timeframe for this update.
WoTPy
Introduction
WoTPy is an experimental implementation of a W3C WoT Runtime and the W3C WoT Scripting API in Python.
Inspired by the exploratory implementations located in the thingweb GitHub page.
Features
- Supports Python 2.7 and Python 3.
- Fully-implemented
WoT
interface. - Multicast discovery based on mDNS.
- Asynchronous I/O programming model based on coroutines.
- Multiple client and server Protocol Binding implementations.
Feature support matrix
Feature | Python 2.7 | Python 3 | Implementation based on |
---|---|---|---|
HTTP binding | :heavy_check_mark: | :heavy_check_mark: | tornadoweb/tornado |
WebSockets binding | :heavy_check_mark: | :heavy_check_mark: | tornadoweb/tornado |
CoAP binding | :heavy_multiplication_x: | :heavy_check_mark: | chrysn/aiocoap |
MQTT binding | :heavy_multiplication_x: | :heavy_check_mark: | beerfactory/hbmqtt |
mDNS discovery | :heavy_multiplication_x: | :heavy_check_mark: | jstasiak/python-zeroconf |
Couroutine APIs
WoTPy is based on the Tornado Framework. Users therefore have two different API options to write code based on coroutines:
- Users on Python 3 may use the native asyncio module. This is, in fact, the recommended approach. It should be noted that Tornado on Python 3 acts basically as a wrapper around
asyncio
. - Users on Python 2.7 are restricted to writing Tornado coroutines (
asyncio
is not available on Python 2.7).
Installation
pip install wotpy
Development
To install in development mode with all the test dependencies:
pip install -U -e .[tests]
To run the tests in all supported environments:
WOTPY_TESTS_MQTT_BROKER_URL=mqtt://broker-url tox
Some WoTPy features (e.g. CoAP binding) are not available outside of Linux. If you have Docker available in your system, and want to easily run the tests in a Linux environment (whether you're on macOS or Windows) you can use the Docker-based test script:
$ WOTPY_TESTS_MQTT_BROKER_URL=mqtt://192.168.1.141 ./pytest-docker-all.sh
...
+ docker run --rm -it -v /var/folders/zd/02pk7r3954s_t03lktjmvbdc0000gn/T/wotpy-547bed6bacf34ddc95b41eceb46553dd:/app -e WOTPY_TESTS_MQTT_BROKER_URL=mqtt://192.168.1.141 python:3.9 /bin/bash -c 'cd /app && pip install -U .[tests] && pytest -v --disable-warnings'
...
Python 2.7 :: OK
Python 3.6 :: OK
Python 3.7 :: OK
Python 3.8 :: OK
Python 3.9 :: OK
Docs
Move to the docs
folder and run:
make html
If you attempt to build the docs on a non-Linux platform or with Python 2.7 _autosummary
will complain about being unable to import the unsupported modules (e.g. MQTT on Python 2.7). In this case the docs will be missing the sections regarding unsupported features.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file wotpy-0.16.0.tar.gz
.
File metadata
- Download URL: wotpy-0.16.0.tar.gz
- Upload date:
- Size: 98.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.7.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b9baef05eded290ab40c9b20e3c52fa4151cfd187906a822eab0820c77856256 |
|
MD5 | 1e863ef6da139135cddfd7c675636354 |
|
BLAKE2b-256 | 62075d97c5642996b506567a6dbdb2801a0b87ca66666dd02fcc84e9284034f2 |
File details
Details for the file wotpy-0.16.0-py3-none-any.whl
.
File metadata
- Download URL: wotpy-0.16.0-py3-none-any.whl
- Upload date:
- Size: 152.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.7.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c17ef0eb8a34d5cb39822f980a54fbbd9a90bc0d27282fc65aeab9907026e1f8 |
|
MD5 | fe3b6005587ed1ea3399408b3ee6e68e |
|
BLAKE2b-256 | fd72036741493ff68121f7d6ad9bc8c828000f08c924bb777142e1c3ab6be68b |