{ "info": { "author": "Filip \u0160", "author_email": "projects@filips.si", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 3", "Topic :: Communications", "Topic :: Internet", "Topic :: Software Development :: Libraries", "Topic :: Utilities" ], "description": "ZeroFramePy\n===========\n\n[![version][icon-version]][link-pypi]\n[![downloads][icon-downloads]][link-pypi]\n[![license][icon-license]][link-license]\n[![python][icon-python]][link-python]\n[![build][icon-travis]][link-travis]\n\nZeroFrame WebSocket API for Python.\n\n## Description\n\nThis is Python WebSocket client for [ZeroFrame API][link-zeroframe]. It supports (almost) same features as default ZeroFrame that is included in ZeroNet sites, but it is using WebSocket client so it can be used in local programs.\n\n## Installation\n\n### Requirements\n\nContentHash requires Python 3.5 or higher.\n\n### From PyPI\n\nThe recommended way to install ContentHash is from PyPI with PIP.\n\n```bash\npip install zeroframe-ws-client\n```\n\n### From Source\n\nAlternatively, you can also install it from the source.\n\n```bash\ngit clone https://github.com/filips123/ZeroFramePy.git\ncd ZeroFramePy\npython setup.py install\n```\n\n## Usage\n\n### Importing Package\n\nYou can import ZeroFrameJS from `zeroframe_ws_client` package.\n\n```py\nfrom zeroframe_ws_client import ZeroFrame\n```\n\n### Creating Connection\n\nTo create a connection, you need to specify the ZeroNet site address.\n\n```py\nzeroframe = ZeroFrame('1HeLLo4uzjaLetFx6NH3PMwFP3qbRbTf3D')\n```\n\nIf ZeroNet instance is using `Multiuser` plugin, you need to specify a master address of the account you want to use. Account must already exist on the instance.\n\n```py\nzeroframe = ZeroFrame(\n '1HeLLo4uzjaLetFx6NH3PMwFP3qbRbTf3D',\n multiuser_master_address='1Hxki73XprDRedUdA3Remm3kBX5FZxhFR3'\n)\n```\n\nIf you want to create a new account, you also need to specify a master seed of it. Note that this feature is unsafe on the untrusted proxy. Also, it is currently not implemented yet.\n\n```py\nzeroframe = ZeroFrame(\n '1HeLLo4uzjaLetFx6NH3PMwFP3qbRbTf3D',\n multiuser_master_address='1KAtuzxwbD1QuMHMuXWcUdoo5ppc5wnot9',\n multiuser_master_seed='fdbaf75427ba69a3d4aa8e19372e05879e9e2d866e579dd30be25e6fab7e3fb2'\n)\n```\n\nIf needed, you can also specify protocol, host and port of ZeroNet instance.\n\n```py\nzeroframe = ZeroFrame(\n '1HeLLo4uzjaLetFx6NH3PMwFP3qbRbTf3D',\n instance_host='192.168.1.1',\n instance_port=8080,\n instance_secure=True\n)\n```\n\nLog and error message from `zeroframe.log` and `zeroframe.error` will not be displayed by default. If you want to, you can also display them as debug info.\n\n```py\nzeroframe = ZeroFrame(\n '1HeLLo4uzjaLetFx6NH3PMwFP3qbRbTf3D',\n show_log=True,\n show_error=True\n)\n```\n\nBy default, the client will try to reconnect WebSocket if the connection was closed every 5 seconds. You can also configure time delay and total attempts. Delay is specified in milliseconds. The number of attempts `-1` means infinity and `0` means zero (disabled reconnecting).\n\n```py\nzeroframe = ZeroFrame(\n '1HeLLo4uzjaLetFx6NH3PMwFP3qbRbTf3D',\n reconnect_attempts=10,\n reconnect_delay=1000\n)\n```\n\nThe client will then obtain wrapper key to the site and connect to WebSocket using it.\n\nYou can now normally use ZeroFrame API. Just remember that there is no wrapper, so wrapper commands are not available. The client is connected directly to the WebSocket server, so you need to use its commands.\n\nNote that the WebSocket server sometimes sends commands (`notification`, `progress`, `error`, `prompt`, `confirm`, `setSiteInfo`, `setAnnouncerInfo`, `updating`, `redirect`, `injectHtml`, `injectScript`) that are normally handled by the wrapper. Because there is no wrapper, you need to handle those commands yourself if needed. Commands `response` and `ping` are already handled by this client so you don't need to handle them.\n\n### Sending Command\n\nYou can use the `cmd` method to issue commands.\n\n```py\nzeroframe.cmd(\n 'siteInfo',\n {},\n lambda result: print(result)\n)\n```\n\nYou can also use the `cmdp` method to get results as Python asyncio futures.\n\n```py\nresult = zeroframe.cmd('siteInfo', {})\nprint(result.result())\n```\n\n### Sending Response\n\nTo submit responses, you need to use `response` command.\n\n```py\nzeroframe.response(10, 'Hello World')\n```\n\n### Logging Information\n\nThere are also `log` and `error` methods which are available for logging. They will display output to console if enabled.\n\n```py\nzeroframe.log('Connected')\nzeroframe.error('Connection failed')\n```\n\n### Handling Connection\n\nThere are also public handler methods which you can overwrite to add your own logic to ZeroFrame.\n\n```py\nclass ZeroApp(ZeroFrame):\n def on_request(self, cmd, message):\n if cmd == 'helloWorld':\n self.log('Hello World')\n\n def on_open_websocket(self):\n self.log('Connected to WebSocket')\n\n def on_error_websocket(self, error):\n self.error('WebSocket connection error')\n\n def on_close_websocket(self):\n self.error('WebSocket connection closed')\n```\n\n### Calling Commands Directly\n\nYou can also directly call commands via `__getattr__` method. Command name is accepted as an object's property and parameters are accepted as a method's arguments. Command returns `asyncio.Future` with the result.\n\n * Command with no arguments can be accessed with `zeroframe.cmdName()`.\n * Command with keyword arguments can be accessed with `zeroframe.cmdName(key1=value1, key2=value2)`.\n * Command with normal arguments can be accessed with `zeroframe.cmdName(value1, value2)`.\n\n```py\nsiteInfo = zeroframe.siteInfo()\nprint(siteInfo.result())\n```\n\n### Other Examples\n\nYou could also look to [`example.py`][link-example].\n\n## Versioning\n\nThis library uses [SemVer][link-semver] for versioning. For the versions available, see [the tags][link-tags] on this repository.\n\n## License\n\nThis library is licensed under the MIT license. See the [LICENSE][link-license-file] file for details.\n\n[icon-version]: https://img.shields.io/pypi/v/zeroframe-ws-client.svg?style=flat-square&label=version\n[icon-downloads]: https://img.shields.io/pypi/dm/zeroframe-ws-client.svg?style=flat-square&label=downloads\n[icon-license]: https://img.shields.io/pypi/l/zeroframe-ws-client.svg?style=flat-square&label=license\n[icon-python]: https://img.shields.io/pypi/pyversions/zeroframe-ws-client.svg?style=flat-square&label=python\n[icon-travis]: https://img.shields.io/travis/com/filips123/ZeroFramePy.svg?style=flat-square&labelbuild\n\n[link-pypi]: https://pypi.org/project/zeroframe-ws-client/\n[link-license]: https://choosealicense.com/licenses/mit/\n[link-python]: https://python.org/\n[link-travis]: https://travis-ci.com/filips123/ZeroFramePy/\n[link-semver]: https://semver.org/\n\n[link-tags]: https://github.com/filips123/ZeroFramePy/tags/\n[link-license-file]: https://github.com/filips123/ZeroFramePy/blob/master/LICENSE\n[link-example]: https://github.com/filips123/ZeroFramePy/blob/master/example.py\n\n[link-zeroframe]: https://zeronet.io/\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/filips123/ZeroFramePy/", "keywords": "zeronet,zeroframe,websocket,library,p2p,decentralized", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "zeroframe-ws-client", "package_url": "https://pypi.org/project/zeroframe-ws-client/", "platform": "", "project_url": "https://pypi.org/project/zeroframe-ws-client/", "project_urls": { "Homepage": "https://github.com/filips123/ZeroFramePy/" }, "release_url": "https://pypi.org/project/zeroframe-ws-client/1.0.1/", "requires_dist": [ "websocket-client (<0.57.0,>=0.56.0)", "pylint ; extra == 'lint'" ], "requires_python": ">= 3.5", "summary": "ZeroFrame WebSocket API for Python", "version": "1.0.1" }, "last_serial": 5830199, "releases": { "1.0.0": [ { "comment_text": "", "digests": { "md5": "3cb69274f201d5c2e16557d271c6a293", "sha256": "fac548b1b0d6a7967874a8860c5d42faf3637e2b62650d69d23c902c3c927cc4" }, "downloads": -1, "filename": "zeroframe_ws_client-1.0.0-py3-none-any.whl", "has_sig": false, "md5_digest": "3cb69274f201d5c2e16557d271c6a293", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">= 3.5", "size": 7879, "upload_time": "2019-09-04T17:47:32", "url": "https://files.pythonhosted.org/packages/0b/87/acc60c8665db3d9ecb3aca8e38875419a5f7b6b00eda6bea67f528426fd0/zeroframe_ws_client-1.0.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "b4c4e9aa52558260c6c08d675a31aaca", "sha256": "b326c33d54d5b93f28e680da7dd6f22e1a6d479ab30b294e5288bb1a8239f21c" }, "downloads": -1, "filename": "zeroframe-ws-client-1.0.0.tar.gz", "has_sig": false, "md5_digest": "b4c4e9aa52558260c6c08d675a31aaca", "packagetype": "sdist", "python_version": "source", "requires_python": ">= 3.5", "size": 8576, "upload_time": "2019-09-04T17:47:34", "url": "https://files.pythonhosted.org/packages/47/92/d0072e43f7222432b14c1ade9e59a3b4dec36caec46c37bba1b5698e2f4b/zeroframe-ws-client-1.0.0.tar.gz" } ], "1.0.1": [ { "comment_text": "", "digests": { "md5": "e5a6223da74ff10b9a84dc14755ec140", "sha256": "ae5b29361904a2dad6310e6442eba748f6ab224a3e4769e3a2694f0b7ad64593" }, "downloads": -1, "filename": "zeroframe_ws_client-1.0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "e5a6223da74ff10b9a84dc14755ec140", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">= 3.5", "size": 7967, "upload_time": "2019-09-14T20:50:56", "url": "https://files.pythonhosted.org/packages/f4/48/70a234338c73513a12b54fd10f89020b8c7c8505ea0e3ef0b72a4e0bdf3b/zeroframe_ws_client-1.0.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "be5f6de2045fd0b2b591fbd32642c29d", "sha256": "5f3f631e672f7f2732cdb596a6a0efd061267c5fae582f173bdc02074c52ecfa" }, "downloads": -1, "filename": "zeroframe-ws-client-1.0.1.tar.gz", "has_sig": false, "md5_digest": "be5f6de2045fd0b2b591fbd32642c29d", "packagetype": "sdist", "python_version": "source", "requires_python": ">= 3.5", "size": 8782, "upload_time": "2019-09-14T20:50:58", "url": "https://files.pythonhosted.org/packages/ca/a9/4226e30cfc57cec9b1bef70422564c0f4f6e974eea275beb087ff5242f70/zeroframe-ws-client-1.0.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "e5a6223da74ff10b9a84dc14755ec140", "sha256": "ae5b29361904a2dad6310e6442eba748f6ab224a3e4769e3a2694f0b7ad64593" }, "downloads": -1, "filename": "zeroframe_ws_client-1.0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "e5a6223da74ff10b9a84dc14755ec140", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">= 3.5", "size": 7967, "upload_time": "2019-09-14T20:50:56", "url": "https://files.pythonhosted.org/packages/f4/48/70a234338c73513a12b54fd10f89020b8c7c8505ea0e3ef0b72a4e0bdf3b/zeroframe_ws_client-1.0.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "be5f6de2045fd0b2b591fbd32642c29d", "sha256": "5f3f631e672f7f2732cdb596a6a0efd061267c5fae582f173bdc02074c52ecfa" }, "downloads": -1, "filename": "zeroframe-ws-client-1.0.1.tar.gz", "has_sig": false, "md5_digest": "be5f6de2045fd0b2b591fbd32642c29d", "packagetype": "sdist", "python_version": "source", "requires_python": ">= 3.5", "size": 8782, "upload_time": "2019-09-14T20:50:58", "url": "https://files.pythonhosted.org/packages/ca/a9/4226e30cfc57cec9b1bef70422564c0f4f6e974eea275beb087ff5242f70/zeroframe-ws-client-1.0.1.tar.gz" } ] }