{ "info": { "author": "Twiddly", "author_email": "twiddly@pewpew.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Environment :: Other Environment", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python :: 3", "Topic :: Software Development :: Libraries" ], "description": "# happypandax-client\n> A python client library for communicating with [HappyPanda X](https://github.com/happypandax/happypandax) servers\n\n

\n\n## Installing\n\nInstall and update using pip\n\n```\n$ pip3 install happypandax-client\n```\n\n## Example\n\nGet up and running fast:\n\n```python\nimport happypandax_client as hpxclient\nfrom pprint import pprint\n\nc = hpxclient.Client(\"my-client\")\nc.connect(host=\"localhost\", port=7007)\n\nc.handshake(user = None, password = None)\nd = c.send([{\"fname\": \"get_version\"}])\npprint(d)\n```\n\n## API\n\n#### Client (name, host=\"localhost\", port=7007, session_id=\"\", ssl_context=None, timeout=60) \u00e2\u2020\u2019 A Client instance\n\nA client for communicating with a HappyPanda X server.\n\nArgs:\n\n- `name`: name of client\n- `host`: HPX server host\n- `port`: HPX server host\n- `session_id`: if provided, this will be the session id used in messages\n- `ssl_context`: see [`ssl.create_default_context`](https://docs.python.org/3/library/ssl.html#ssl.create_default_context)\n- `timeout`: see [`socket.settimeout`](https://docs.python.org/3/library/socket.html#socket.socket.settimeout) \n\n#### Client.host _(property)_ \u00e2\u2020\u2019 str\n\nSet or return the HPX server host\n\n#### Client.port _(property)_ \u00e2\u2020\u2019 int\n\nSet or return the HPX server port\n\n#### Client.accepted _(property)_ \u00e2\u2020\u2019 bool\n\nWhether this client has been authenticated or not (this value will only be available after connecting)\n\n#### Client.version _(property)_ \u00e2\u2020\u2019 dict\n\nThe version message returned from the HPX server (this value will only be available after connecting)\n\n#### Client.guest_allowed _(property)_ \u00e2\u2020\u2019 bool\n\nWhether guests are allowed on the connected HPX server (this value will only be available after connecting)\n\n#### Client.ready () \u00e2\u2020\u2019 bool\n\nWhether this client is ready to exchange messages with the HPX server\n\n#### Client.alive () \u00e2\u2020\u2019 bool\n\nWhether the connection is still alive\n\n#### Client.connect (self, host=None, port=None) \u00e2\u2020\u2019 bool\n\nConnect to HPX server\n\nArgs:\n\n- `host`: HPX server host, if set to `None` the provided host on instantiation will be used\n- `port`: HPX server port, if set to `None` the provided port on instantiation will be used\n\n#### Client.handshake (self, user=None, password=None, ignore_err=False, _data={}) \u00e2\u2020\u2019 bool\n\nPerfom a handshake with the HPX server\n\nArgs:\n\n- `user`: username\n- `password`: password\n- `ignore_err`: don't raise any errors\n\n#### Client.request_handshake (self, user=False, password=False, ignore_err=False) \u00e2\u2020\u2019 bool\n\nBasically a re-login\n\nArgs:\n\n- `user`: username, if set to `False` the previously provided username will be used\n- `password`: password, if set to `False` the previously provided password will be used\n- `ignore_err`: don't raise any errors\n\n#### Client.send_bytes (self, data, raise_on_auth=True) \u00e2\u2020\u2019 bytes\n\nSend bytedata to server. Receive bytedata from server.\n\nArgs:\n\n- `data`: bytes data to send to server\n- `raise_on_auth`: raise an error if client is not authenticated\n\n#### Client.send_raw (self, data, raise_on_auth=True, encoding='utf-8') \u00e2\u2020\u2019 dict\n\nSend json-compatible dict to server. Receive json-compatible from server.\n\nNote that this method will not add anything to your message and expects you to add the name and session yourself. See the *finalize* function.\n\nArgs:\n\n- `data`: data to send to server, this is a dict\n- `raise_on_auth`: raise an error if client is not authenticated\n- `encoding`: bytes encoding, there shouldn't be a reason to change this\n\n#### Client.send (self, data, raise_on_auth=True, encoding='utf-8') \u00e2\u2020\u2019 dict\n\nLike *Client.send_raw*, but as a convenience, this method will wrap your message into the required message structure HPX expects and automatically sets the session and name:\n```python\nfinal_msg = {\n 'session': client.session_id,\n 'name': client.name,\n 'data': data, # <--- your message is put here\n }\n```\n\nArgs:\n\n- `data`: data to send to server, this is usually a list of dicts\n- `raise_on_auth`: raise an error if client is not authenticated\n- `encoding`: bytes encoding, there shouldn't be a reason to change this\n\n#### Client.close () \u00e2\u2020\u2019 None\n\nClose connection with server. Note that it won't be possible to connect again after the connection has been closed.\n\n#### finalize (name, data, session_id=\"\") \u00e2\u2020\u2019 dict\n\nA helper function that will wrap your message up like this:\n\n```python\nmsg = {\n 'session': session_id,\n 'name': name,\n 'data': data, # <--- your message is put here\n }\n```\n\nArgs:\n\n- `name`: name of client\n- `data`: data to send to server, this is usually a list of dicts\n- `session_id`: session id\n\n---------------------------------------------------------------\n\nThese are all the exceptions that can be raised by the client:\n\n#### ClientError(Exception)\nBase client exception, all client exceptions will derive from this\n\n#### ConnectionError(ClientError, ConnectionError)\nServer connection error\n\n#### ServerDisconnectError(ConnectionError, ConnectionAbortedError)\nServer disconnected\n\n#### AuthError(ClientError)\nAuth Base Error\n\n#### AuthRequiredError(AuthError)\n\n#### AuthWrongCredentialsError(AuthError)\n\n#### AuthMissingCredentials(AuthError)\n\n#### JSONParseError(ClientError)\n\n## Extra\n\n### Using a different json library\n\nIt must support being used as a drop-in replacement for the standard `json` module\n\n```\nimport happypandax_client as hpxclient\nimport ujson\nhpxclient.client.json = ujson\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/happypandax/py-client", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "happypandax-client", "package_url": "https://pypi.org/project/happypandax-client/", "platform": "", "project_url": "https://pypi.org/project/happypandax-client/", "project_urls": { "Homepage": "https://github.com/happypandax/py-client" }, "release_url": "https://pypi.org/project/happypandax-client/1.0.0/", "requires_dist": null, "requires_python": "", "summary": "Client library for communicating with HappyPanda X servers", "version": "1.0.0" }, "last_serial": 5288760, "releases": { "1.0.0": [ { "comment_text": "", "digests": { "md5": "ddf63929b7fd420338f30b0b2b387280", "sha256": "10796ba034a9526dbd29e1a68a5a9cb8426e7977f193e91adbaf00ca0447e936" }, "downloads": -1, "filename": "happypandax_client-1.0.0-py3-none-any.whl", "has_sig": false, "md5_digest": "ddf63929b7fd420338f30b0b2b387280", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 7886, "upload_time": "2019-05-19T16:48:57", "url": "https://files.pythonhosted.org/packages/35/56/9c17c7c3bc7b60951c7d728cb7c8abb8b7bd30e43a9b5da4efc0a20bfbd6/happypandax_client-1.0.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "7b9933decd693e9e7f59ed7377f962a2", "sha256": "b1485c4039eb8d07989c43b88fe54af337e8e59b47cbc7a9d87419516ba252d8" }, "downloads": -1, "filename": "happypandax-client-1.0.0.tar.gz", "has_sig": false, "md5_digest": "7b9933decd693e9e7f59ed7377f962a2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6110, "upload_time": "2019-05-19T16:48:59", "url": "https://files.pythonhosted.org/packages/71/83/4f4ccdfc4bd12a6febb77e5422cfa8fa4c813ba7f12c0f6dc358a2b3e2c9/happypandax-client-1.0.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "ddf63929b7fd420338f30b0b2b387280", "sha256": "10796ba034a9526dbd29e1a68a5a9cb8426e7977f193e91adbaf00ca0447e936" }, "downloads": -1, "filename": "happypandax_client-1.0.0-py3-none-any.whl", "has_sig": false, "md5_digest": "ddf63929b7fd420338f30b0b2b387280", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 7886, "upload_time": "2019-05-19T16:48:57", "url": "https://files.pythonhosted.org/packages/35/56/9c17c7c3bc7b60951c7d728cb7c8abb8b7bd30e43a9b5da4efc0a20bfbd6/happypandax_client-1.0.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "7b9933decd693e9e7f59ed7377f962a2", "sha256": "b1485c4039eb8d07989c43b88fe54af337e8e59b47cbc7a9d87419516ba252d8" }, "downloads": -1, "filename": "happypandax-client-1.0.0.tar.gz", "has_sig": false, "md5_digest": "7b9933decd693e9e7f59ed7377f962a2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6110, "upload_time": "2019-05-19T16:48:59", "url": "https://files.pythonhosted.org/packages/71/83/4f4ccdfc4bd12a6febb77e5422cfa8fa4c813ba7f12c0f6dc358a2b3e2c9/happypandax-client-1.0.0.tar.gz" } ] }