Skip to main content

A library to wrap a python object onto the Wotio Operating Enviroment

Project description

wotwrapper
========

A python library to wrap python objects onto Wotio

About
-----

Most APIs are wrapped in python as classes, of which you'd instantiate an object and call it's methods. This library wraps those functions onto the Wotio environment, allowing you to publish data to it, and access the API via s-expressions in JSON.

Example:

```python
class MyClass(object):
def getdata(self):
return "Some Data"
def somefunc(self, param):
return "Function called with parameter: {0}".format(param)
```

Those functions then become available on the bus using the JSON arrays:

```javascript
["getdata"]
["somefunc","param"]
```

In addition, a function can be used to publish data onto the bus consistently. The wrapper contains a loop that will call a specific function and publish its data periodically. More info below.

Getting Started
---------------

To install, run:

```shell
pip install wotwrapper
```

To use it, include it in your project and wrap an object:

```python
import wotwrapper
from phue import Bridge

b = Bridge('192.168.24.10')
wotwrapper.connect('http://wot.io/account/path', b, b.get_api, 10)

```

Parameters
----------

```python
wotwrapper.connect(path, objectToWrap, sendDataFunction, delay)
```

- **path:** This is the path for either the HTTP or Websocket endpoint that will be connected to. The path is in the format: `(http|ws)://host/account/in_exchange/in_key/in_queue/out_exchange/out_key/token`

- **objectToWrap:** This is the obejct to be wrapped.

- **sendDataFunction:** This is the function that provides the data to be published. Note that it does not have to be part of the same object.

- **delay:** This specifies the delay, in seconds, between each iteration of the data publishing loop.

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

wotwrapper-0.0.7.tar.gz (2.9 kB view details)

Uploaded Source

File details

Details for the file wotwrapper-0.0.7.tar.gz.

File metadata

  • Download URL: wotwrapper-0.0.7.tar.gz
  • Upload date:
  • Size: 2.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for wotwrapper-0.0.7.tar.gz
Algorithm Hash digest
SHA256 10fd422ef0e17235341a9233cc7caecba790f5caf04952f4b2b6bf59f2175b23
MD5 fc36886b0dcb2bf326c23d4b75169d8e
BLAKE2b-256 60479652c1af89be28a26d3805c81bc82acb6688e77ac23840a929b1828ee0b8

See more details on using hashes here.

Supported by

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