Disruptive Technologies Python Client
Documentation
Installation
The package can be installed through pip:
pip install --upgrade disruptive
or from source:
pip install .
Requirements
- Python 3.9-3.13
Authentication
The package is authenticated by providing Service Account credentials in either of the following ways.
- By setting the following environment variables:
export DT_SERVICE_ACCOUNT_KEY_ID="<SERVICE_ACCOUNT_KEY_ID>"
export DT_SERVICE_ACCOUNT_SECRET="<SERVICE_ACCOUNT_SECRET>"
export DT_SERVICE_ACCOUNT_EMAIL="<SERVICE_ACCOUNT_EMAIL>"
- By providing the credentials programmatically:
import disruptive as dt
dt.default_auth = dt.Auth.service_account(
key_id="<SERVICE_ACCOUNT_KEY_ID>",
secret="<SERVICE_ACCOUNT_SECRET>",
email="<SERVICE_ACCOUNT_EMAIL>",
)
See Python API Authentication for more details.
Usage
Once authenticated, most functionality can be accessed through resource methods on the following format.
disruptive.<Resource>.<method>()
A few common uses are showcased in the snippet below. See the Python API Reference for full documentation.
import disruptive as dt
# Fetch a sensor, specified by its ID.
sensor = dt.Device.get_device('<DEVICE_ID>')
# Printing the returned object will list all attributes.
print(sensor)
# Set a new label on the sensor.
dt.Device.set_label(sensor.device_id, sensor.project_id, key='nb', value='99')
# Get touch- and temperature event history for the sensor.
history = dt.EventHistory.list_events(
sensor.device_id,
sensor.project_id,
event_types=[
dt.events.TOUCH,
dt.events.TEMPERATURE,
]
)
# Initiate an event stream for all devices in the sensor's project.
for event in dt.Stream.event_stream(sensor.project_id):
# Print new events data as they arrive.
print(event.data)
Logging
The simplest method is enabled by setting disruptive.log_level.
dt.log_level = dt.logging.INFO
If more fine-grained control is desired, the standard library logging can also be used.
logging.basicConfig(
filename='example.log',
format='[%(asctime)s.%(msecs)03d] %(levelname)-8s - %(message)s',
datefmt='%Y-%m-%d %H:%M:%S',
)
logging.getLogger('disruptive').setLevel(logging.INFO)
For both methods, the standard levels DEBUG, INFO, WARNING, ERROR, and CRITICAL are supported.
Examples
A few examples has been provided. Before running, the required environment variables listed at the start of each example must be set.
python examples/example_name.py
Exceptions
If a request is unsuccessful or has been provided with invalid parameters, an exception is raised. A list of available exceptions are available in the API Reference.
Development
Set up the development virtualenv environment:
make
Run unit-tests against the currently active python version:
make test
Lint the package code using MyPy and flake8:
make lint
Build the package distribution:
make build
Metadata
Release files for disruptive 1.7.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| disruptive-1.7.3.tar.gz | 59.6 kB | Without provenance | Details for disruptive-1.7.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| disruptive-1.7.3-py3-none-any.whl | Python 3 | none | any | Details for disruptive-1.7.3-py3-none-any.whl |
Total release size: 114.0 kB
Release files / disruptive-1.7.3.tar.gz
| Download URL | disruptive-1.7.3.tar.gz |
|---|---|
| Size | 59.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0d4d41707bf910150b44bfd2ccf04e8e54444d3d7ad7ce9e04ff6e8e6182fc82
|
|
BLAKE2b-256 checksum How to use checksums |
b5f9f0e86b2c8bce256b529beb4c64170f2dca4581030ffec3f49b8a94d9b652
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Release files / disruptive-1.7.3-py3-none-any.whl
| Download URL | disruptive-1.7.3-py3-none-any.whl |
|---|---|
| Size | 54.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b5ca16d24572ad654082efa96b950c27f71da08c0c5a5abdcbfc8b1465d5e284
|
|
BLAKE2b-256 checksum How to use checksums |
2e6c55189299b0d1764a57be560e9f6a0447b54b97d6e3b47950d3b2f0bd955d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Security for disruptive 1.7.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.