{ "info": { "author": "David Khudaverdyan", "author_email": "khudaverdyan.david@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Natural Language :: English", "Operating System :: OS Independent", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.6", "Topic :: Software Development :: Libraries" ], "description": "# dataRT Python Library\n\n## About\n\n### What does dataRT do?\ndataRT is a drop-in replacement for the InfluxDBClient which writes data to InfluxDB while simultaneously echoing the points to a WebSocket. This allows you to view the data in real-time in a web browser or other client.\n\n### What scenario would I need this for?\ndataRT is designed to be used where the InfluxDBClient is already being used but constantly querying InfluxDB does not provide adequate real-time access to your data. By creating a client webpage you can display the data __in real time__ while simultaneously recording the points in InfluxDB for examination at a later date.\n\n### What if I don't want to use InfluxDB?\nNo problem!\nInfluxDB is __not__ a requirement to use dataRT. If the `influx_url` argument is set to `None`, dataRT will echo the data to a WebSocket, but not attempt to send data to an InfluxDB instance.\n\n## Installation\n\n### PyPi\n```bash\n> pip install dataRT\n```\n\n### Setuptools\n```bash\n> python setup.py install\n```\n\n## Usage\n### Single-Thread Application\nIf you are constrained for resources, you can use the `CoreClient` object.\n\nIt is highly recommended that you [monkey-patch](http://www.gevent.org/intro.html#beyond-sockets) using gevent when using this technique.\n\nTo start, import the `CoreClient`:\n```python\nfrom dataRT import CoreClient\n```\n\nThen create a client:\n```python\nclient = CoreClient(influx_url=None, debug=True)\n```\n\nThe `CoreClient` takes these arguments, all are optional:\n\n| Keyword | Default | Description |\n| ------- | ------- | ----------- |\n| `host` | `'0.0.0.0'` | Bind host for the WebSocket |\n| `port` | `8080` | Bind port for the WebSocket |\n| `influx_url` | `'localhost'` | URL for InfluxDB. Note: if this is set to `None` no attempt to connect to an InfluxDB instance will be made |\n| `influx_port` | `8086` | Port for InfluxDB |\n| `influx_user` | `None` | Username for InfluxDB |\n| `influx_pass` | `None` | Password for InfluxDB |\n| `influx_db` | `'example'` | Database for InfluxDB |\n| `websocket_path` | `r'/ws'` | Base path for accessing WebSocket resources |\n| `debug` | `False` | Show debug messages |\n\nDefine a \"action\" function then start the dataRT loop. This function will be constantly called as the dataRT runs through its maintenance loop:\n```python\ndef action(possible_arg, possible_kwarg=100):\n print(possible_arg)\n print(possible_kwarg)\n\nclient.run_in_loop(action, 'possible_arg', possible_kwarg=1000)\n```\n\nOnce `run_in_loop` is called, the client blocks until `client.stop()` is called or the program exits.\n\nAvailable client functions:\n\n| Method | Arguments | Description |\n| ------ | --------- | ----------- |\n| `write_points` | `points`, `*args`, `**kwargs` | Writes points to the WebSocket and InfluxDB instance. `points` are used for the WebSocket, all other args are passed to the InfluxDBClient |\n| `query` | `*args`, `**kwargs` | Passes a query to the InfluxDBClient |\n| `create_database` | `*args`, `**kwargs` | Passes a `create_database` to the InfluxDBClient |\n| `serve_forever` | `None` | Blocks and serves the WebSocket forever |\n| `start` | `None` | Starts the WebSocket server |\n| `stop` | `None` | Stops the WebSocket server |\n| `run_in_loop` | `actions`, `*args`, `**kwargs` | Blocks and serves the WebSocket forever, but calls the `actions` function every loop with the provided `*args` and `**kwargs` |\n\nAvailable client properties:\n\n| Property | Can be set? | Type | Description |\n| -------- | ----------- | ---- | ----------- |\n| `is_serving` | No | `bool` | Returns `True` if the WebSocket is currently being served |\n| `influx_client` | No | `InfluxDBClient` | Returns the InfluxDBClient object to be used with more complex InfluxDB operations |\n| `ws_on_message` | Yes | function | Function to call when the WebSocket receives a new message. Should accept 2 args for the WebSocket client and the message (string) |\n| `ws_on_connect` | Yes | function | Function to call when the WebSocket connects. Should accept 1 arg for the WebSocket client |\n| `ws_on_disconnect` | Yes | function | Function to call when the WebSocket disconnects. Should accept 1 arg for the WebSocket client |\n\n### Multi-Process Application\nIf you need more reliability or want to avoid your code possibly blocking dataRT background tasks, use the `Client` object.\n\nTo start, import the `Client`:\n```python\nfrom dataRT import Client\n```\n\nThen create a client:\n```python\nclient = Client(influx_url=None, debug=True)\n```\n\nThe `Client` takes these arguments, all are optional:\n\n| Keyword | Default | Description |\n| ------- | ------- | ----------- |\n| `host` | `'0.0.0.0'` | Bind host for the WebSocket |\n| `port` | `8080` | Bind port for the WebSocket |\n| `influx_url` | `'localhost'` | URL for InfluxDB. Note: if this is set to `None` no attempt to connect to an InfluxDB instance will be made |\n| `influx_port` | `8086` | Port for InfluxDB |\n| `influx_user` | `None` | Username for InfluxDB |\n| `influx_pass` | `None` | Password for InfluxDB |\n| `influx_db` | `'example'` | Database for InfluxDB |\n| `websocket_path` | `r'/ws'` | Base path for accessing WebSocket resources |\n| `debug` | `False` | Show debug messages |\n\nOnce the client is defined, you can start it:\n```python\nclient.start()\n```\n\nOnce `start` is called, the client will start in another process and continue serving until `client.stop()` is called or the program exits.\n\nAvailable client functions:\n\n| Method | Arguments | Description |\n| ------ | --------- | ----------- |\n| `write_points` | `points` | Writes points to the WebSocket and InfluxDB instance |\n| `start` | `None` | Starts the WebSocket server |\n| `stop` | `None` | Stops the WebSocket server |\n\n### Where is my WebSocket?\nThe WebSocket associates itself with the `client` route on the WebSocket path: `ws:\\\\:\\\\client`.\n\nFor the default settings, this would be `ws:\\\\0.0.0.0:8080\\ws\\client`\n\n## Examples\nExamples can be found in the [examples](examples) directory.\n\n### Library Usage\n\n* [gevent_example.py](examples/gevent_example.py) shows how to integrate the dataRT client in a single-threaded application using gevent. (Note: using this method you must be careful not to block the process from running maintenance for the WebSocket connection otherwise you may encounter issues)\n* [multiprocess_example.py](examples/multiprocess_example.py) shows how to use the dataRT client as a drop-in-place replacement for the InfluxDBClient by leveraging a separate process (Note: This does consume more system resources, use the gevent method if you are working in a resource-constrained environment)\n\n### HTML/JS\n\n* [view_data.html](examples/view_data.html) uses basic jQuery to write each piece of data that is received onto the page in a table.\n* [plot_data.html](examples/plot_data.html) uses the [Chart.js](http://www.chartjs.org) library to plot each point onto a line graph in real time.\n\n## Licensing\nThis project is licensed under the MIT license.\nNo warranty is provided, use at your own risk.\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/thedeltaflyer/dataRT", "keywords": "websocket influxdb realtime", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "dataRT", "package_url": "https://pypi.org/project/dataRT/", "platform": "", "project_url": "https://pypi.org/project/dataRT/", "project_urls": { "Homepage": "https://github.com/thedeltaflyer/dataRT", "Source": "https://github.com/thedeltaflyer/dataRT/", "Tracker": "https://github.com/thedeltaflyer/dataRT/issues" }, "release_url": "https://pypi.org/project/dataRT/0.1.2/", "requires_dist": [ "Flask (>=0.12.2)", "Flask-Sockets (>=0.2.1)", "gevent (>=1.2.2)", "influxdb (>=5.0.0)", "requests (>=2.18.4)", "coverage; extra == 'test'", "pytest; extra == 'test'", "pytest-cov; extra == 'test'" ], "requires_python": "~=3.6", "summary": "A Library for monitoring a datastream in real-time while writing data to WebSocket and InfluxDB", "version": "0.1.2" }, "last_serial": 3790130, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "c391140c6678cd0c22ab24bafc3d9cef", "sha256": "9d04a439ffb5ca5826b039b89abfb2798be366267b42a35670d10a9c7405ab9e" }, "downloads": -1, "filename": "dataRT-0.1.0-py3-none-any.whl", "has_sig": false, "md5_digest": "c391140c6678cd0c22ab24bafc3d9cef", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": "~=3.6", "size": 8640, "upload_time": "2018-04-22T20:46:29", "url": "https://files.pythonhosted.org/packages/11/12/1dc960e513e84249c7bbbf6cb21349177ff5b32caff04932fbe6a29947a0/dataRT-0.1.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "06c0636fdfdbf3127f8be2a834e714e1", "sha256": "511f4fd463e057dd86cd97b2654f4b2629d3d8ccac4d051fe1b3492c921a4153" }, "downloads": -1, "filename": "dataRT-0.1.0.tar.gz", "has_sig": false, "md5_digest": "06c0636fdfdbf3127f8be2a834e714e1", "packagetype": "sdist", "python_version": "source", "requires_python": "~=3.6", "size": 10181, "upload_time": "2018-04-22T20:46:30", "url": "https://files.pythonhosted.org/packages/1d/0e/a68d730901ced2158dd34b868d9cd5955b413a9204bdaab9ee6efa0b9228/dataRT-0.1.0.tar.gz" } ], "0.1.2": [ { "comment_text": "", "digests": { "md5": "a36b81b1d7bfa151f683d9e1b62bc00f", "sha256": "86333b4a8839b3b95d3cd1f38608c34d581486a6fa801a95ada65e88803bad3a" }, "downloads": -1, "filename": "dataRT-0.1.2-py3-none-any.whl", "has_sig": false, "md5_digest": "a36b81b1d7bfa151f683d9e1b62bc00f", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": "~=3.6", "size": 8651, "upload_time": "2018-04-22T22:04:53", "url": "https://files.pythonhosted.org/packages/7a/c9/17876be6ad946d56af816a39e7f3c3f06ac7ac0c2fc963f4bf8320a5ddce/dataRT-0.1.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "0784f952039543d88d6f451df2fb600c", "sha256": "d67e3071da0621f7249db99494a57a98caa3db58032633a381f570a040db988a" }, "downloads": -1, "filename": "dataRT-0.1.2.tar.gz", "has_sig": false, "md5_digest": "0784f952039543d88d6f451df2fb600c", "packagetype": "sdist", "python_version": "source", "requires_python": "~=3.6", "size": 10192, "upload_time": "2018-04-22T22:04:54", "url": "https://files.pythonhosted.org/packages/12/23/55093c36fd12e6eb45c1c9a1cdc5ed5ccf54c18ea9a9e213b2daa7feb78c/dataRT-0.1.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "a36b81b1d7bfa151f683d9e1b62bc00f", "sha256": "86333b4a8839b3b95d3cd1f38608c34d581486a6fa801a95ada65e88803bad3a" }, "downloads": -1, "filename": "dataRT-0.1.2-py3-none-any.whl", "has_sig": false, "md5_digest": "a36b81b1d7bfa151f683d9e1b62bc00f", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": "~=3.6", "size": 8651, "upload_time": "2018-04-22T22:04:53", "url": "https://files.pythonhosted.org/packages/7a/c9/17876be6ad946d56af816a39e7f3c3f06ac7ac0c2fc963f4bf8320a5ddce/dataRT-0.1.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "0784f952039543d88d6f451df2fb600c", "sha256": "d67e3071da0621f7249db99494a57a98caa3db58032633a381f570a040db988a" }, "downloads": -1, "filename": "dataRT-0.1.2.tar.gz", "has_sig": false, "md5_digest": "0784f952039543d88d6f451df2fb600c", "packagetype": "sdist", "python_version": "source", "requires_python": "~=3.6", "size": 10192, "upload_time": "2018-04-22T22:04:54", "url": "https://files.pythonhosted.org/packages/12/23/55093c36fd12e6eb45c1c9a1cdc5ed5ccf54c18ea9a9e213b2daa7feb78c/dataRT-0.1.2.tar.gz" } ] }