Telenor NB-IoT client
Project description
# nbiot-python
[![Travis-CI](https://api.travis-ci.com/telenordigital/nbiot-python.svg)](https://travis-ci.com/telenordigital/nbiot-python)
NBIoT-Python provides a Python client for the REST API for Telenor NB-IoT.
## Configuration
The configuration file is located at `${HOME}/.telenor-nbiot`. The file is a simple
list of key/value pairs. Additional values are ignored. Comments must start
with a `#`:
#
# This is the URL of the Telenor NB-IoT REST API. The default value is
# https://api.nbiot.telenor.io and can usually be omitted.
address=https://api.nbiot.telenor.io
#
# This is the API token. Create new token by logging in to the Telenor NB-IoT
# front-end at https://nbiot.engineering and create a new token there.
token=<your api token goes here>
The configuration file settings can be overridden by setting the environment
variables `TELENOR_NBIOT_ADDRESS` and `TELENOR_NBIOT_TOKEN`. If you only use environment variables
the configuration file can be ignored. Finally, there is a Client constructor that
accepts the address and token directly.
## Updating resources
The various `Client.update*` methods work via HTTP PATCH, which means they will only modify or set fields, not delete them. There are special `Client.delete*tag` methods for deleting tags.
# Sample code
```python
from nbiot import nbiot
client = nbiot.Client()
stream = await client.collection_output_stream('<YOUR_COLLECTION_ID>')
while True:
try:
msg = await stream.recv()
except nbiot.OutputStreamClosed:
break
print(msg.payload)
```
# Development
Development is done using [Pipenv](https://docs.pipenv.org/). Run `pipenv sync --dev` to install all dependencies.
Because Python has not properly solved dependency management yet, dependencies must be be repeated in [setup.py](setup.py) under the `install_requires` entry.
## Testing
Tests are written using [pytest](https://pytest.org/). Run `pipenv run pytest` to run all the tests.
## Deployment
To build and upload a new version to PyPI, make sure that you are using Python 3 and run
```bash
python setup.py sdist
python setup.py bdist_wheel
twine upload dist/* # `pip install twine` to get this tool
```
[![Travis-CI](https://api.travis-ci.com/telenordigital/nbiot-python.svg)](https://travis-ci.com/telenordigital/nbiot-python)
NBIoT-Python provides a Python client for the REST API for Telenor NB-IoT.
## Configuration
The configuration file is located at `${HOME}/.telenor-nbiot`. The file is a simple
list of key/value pairs. Additional values are ignored. Comments must start
with a `#`:
#
# This is the URL of the Telenor NB-IoT REST API. The default value is
# https://api.nbiot.telenor.io and can usually be omitted.
address=https://api.nbiot.telenor.io
#
# This is the API token. Create new token by logging in to the Telenor NB-IoT
# front-end at https://nbiot.engineering and create a new token there.
token=<your api token goes here>
The configuration file settings can be overridden by setting the environment
variables `TELENOR_NBIOT_ADDRESS` and `TELENOR_NBIOT_TOKEN`. If you only use environment variables
the configuration file can be ignored. Finally, there is a Client constructor that
accepts the address and token directly.
## Updating resources
The various `Client.update*` methods work via HTTP PATCH, which means they will only modify or set fields, not delete them. There are special `Client.delete*tag` methods for deleting tags.
# Sample code
```python
from nbiot import nbiot
client = nbiot.Client()
stream = await client.collection_output_stream('<YOUR_COLLECTION_ID>')
while True:
try:
msg = await stream.recv()
except nbiot.OutputStreamClosed:
break
print(msg.payload)
```
# Development
Development is done using [Pipenv](https://docs.pipenv.org/). Run `pipenv sync --dev` to install all dependencies.
Because Python has not properly solved dependency management yet, dependencies must be be repeated in [setup.py](setup.py) under the `install_requires` entry.
## Testing
Tests are written using [pytest](https://pytest.org/). Run `pipenv run pytest` to run all the tests.
## Deployment
To build and upload a new version to PyPI, make sure that you are using Python 3 and run
```bash
python setup.py sdist
python setup.py bdist_wheel
twine upload dist/* # `pip install twine` to get this tool
```
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
telenor-nbiot-0.3.tar.gz
(11.1 kB
view details)
Built Distribution
File details
Details for the file telenor-nbiot-0.3.tar.gz
.
File metadata
- Download URL: telenor-nbiot-0.3.tar.gz
- Upload date:
- Size: 11.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.5.0 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.29.0 CPython/3.7.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 618498a1b381cd7703e519970ff66ac9512f02b9cf8c002a2fa3cd1d22090ab3 |
|
MD5 | 71d5d327fafbf8136965dc9c4b5c7b89 |
|
BLAKE2b-256 | aff7f6311b5acecf54ccb1873aa87d7a5c0a72d0ed9771325bb38641b6323849 |
File details
Details for the file telenor_nbiot-0.3-py3-none-any.whl
.
File metadata
- Download URL: telenor_nbiot-0.3-py3-none-any.whl
- Upload date:
- Size: 10.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.5.0 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.29.0 CPython/3.7.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 783617d71fd5b770fa58be7efcb0a2c83cfca1b71bdae566a90a0ac6bbc3317f |
|
MD5 | 2188275bb4ea5328eaac2e88c6dd6e99 |
|
BLAKE2b-256 | 6680a03d6d677a6d7410f78530ed970d9950b2f836c57a9c80f815d3eced4e5e |