{ "info": { "author": "darkdarkfruit", "author_email": "darkdarkfruit@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python", "Topic :: Internet", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "# What is it?\n\n A python rspmsg module with simplication and modification attached.\n\n\n# Note:\n python version: >=3.6\n\n (For python2.7 version, use rspmsg_version < 0.9, eg: https://github.com/darkdarkfruit/rspmsg/releases/tag/v_0.7.1)\n\n\n# Rspmsg specification\n\n |--------+--------+-----------+-----------+------------+-------------------------------------------------------|\n | Field | type | Required? | Optional? | value | Meaning |\n |--------+--------+-----------+-----------+------------+-------------------------------------------------------|\n | status | string | * | | \"S\" or \"F\" | Is the response successful? |\n | code | any | | * | | CODE for application logic(Normally it is an integer) |\n | data | any | | * | | Data(payload) of the response |\n | desc | any | | * | | Description: normally it's a helping infomation |\n | meta | any | | * | | Meta info. eg: servers/ips chain in distributed env. |\n | | | | | | |\n |--------+--------+-----------+-----------+------------+-------------------------------------------------------|\n\n* Field:status is always in state: \"S\" or \"F\"(represents \"Successful\", \"Failed\"), no 3th state.\n\n## Decide essage type responded in server side\n\n#### When do we set the message as successful or faild? It varies. Here are some suggestions.\n* If the server can reponse with correspondent resource right now, we should mark the message as a 'S' (SUCCESSFUL) message.\n* If the server can **NOT** response with correspondent resource right now, we should mark the message as a 'F' (FAILED) message while setting a meaningful code.\n * eg1:\n \n rspmsg_successful = {\n status : \"S\",\n ...\n }\n \n * eg2:\n\n # If we want to return a response message to tell client that:\n # 1. debug info: the message has flowed to nodes: [\"192.168.1.6\", \"192.168.1.7\"]\n # 2. Please wait 5 seconds to retry.\n # we might response a message like below:\n rspmsg_failed = {\n status : \"F\",\n code : 100,\n data : {\n seconds: 5\n },\n desc : \"Server is busy, please wait 5 seconds to continue\",\n meta : {\n nodes: [\"192.168.1.6\", \"192.168.1.7\"]\n }\n \n\n\n\n# Install:\n * pip install rspmsg or (pip3 install rspmsg)\n Or\n * download the tarbal, decompress it, then run \"python setup.py install\"\n\n# Test:\n # ensure you have the pytest for python3\n > pip3 install pytest\n > whereis pytest\n > pytest: /usr/local/bin/pytest\n > pytest --version\n > This is pytest version 3.3.2, imported from /usr/local/lib/python3.6/site-packages/pytest.py\n >\n > pytest rspmsg/\n\n# API: (only 1 class and 2 functions)\n * class\n \n * Message\n * functions:\n\n * make_successful_message \n * make_failed_message\n\n# FAQ\n* Why use \"S\" and \"F\" to represents \"SUCCESSFUL\" and \"FAILED\"? How about 1 or 0, or true or false.\n \n \n 1. \"S\" and \"F\" is clear and presentative.\n 2. 1 or 0? In many programing languages, 1 stands for true, 0 stands for false; while in linux return code, \n triditionally, 0 stands for successful-code, non-0(eg:1) stands for error-code.\n 3. true or false? In interactive envirenment, we might confuse boolean value: (true, false) with string value\n (\"true\", \"false\"), and that will make us misarable in large project.\n\n# Usage: (sample)\n\n \n Python 3.6.2 (default, Aug 10 2017, 10:07:10) \n Type 'copyright', 'credits' or 'license' for more information\n IPython 6.1.0 -- An enhanced Interactive Python. Type '?' for help.\n \n In [1]: import rspmsg\n ...: \n \n In [2]: rspmsg.__version__\n ...: \n Out[2]: '0.6.0'\n \n In [3]: msg = rspmsg.make_successful_message(code=0, data={'payload' : 'yes'})\n ...: \n \n In [4]: msg\n Out[4]: \n {'code': 0,\n 'data': {'payload': 'yes'},\n 'desc': None,\n 'meta': None,\n 'status': 'S'}\n \n In [5]: msg.dumps()\n Out[5]: '{\"status\": \"S\", \"code\": 0, \"data\": {\"payload\": \"yes\"}, \"desc\": null, \"meta\": null}'\n \n In [6]: msg.dumps(skip_none=True)\n Out[6]: '{\"status\": \"S\", \"code\": 0, \"data\": {\"payload\": \"yes\"}}'\n \n In [7]: msg_failed = rspmsg.make_failed_message()\n ...: \n \n In [8]: msg_failed\n Out[8]: {'code': None, 'data': None, 'desc': None, 'meta': None, 'status': 'F'}\n \n In [9]: msg_failed.dumps()\n Out[9]: '{\"status\": \"F\", \"code\": null, \"data\": null, \"desc\": null, \"meta\": null}'\n \n In [10]: msg_failed.dumps(skip_none=True)\n Out[10]: '{\"status\": \"F\"}'\n \n In [11]: msg_loaded = rspmsg.Message.loads(msg.dumps())\n ...: \n \n In [12]: msg_loaded\n Out[12]: \n {'code': 0,\n 'data': {'payload': 'yes'},\n 'desc': None,\n 'meta': None,\n 'status': 'S'}\n \n In [13]: msg_loaded.data = 0\n \n In [14]: msg_loaded = rspmsg.Message.loads(msg.dumps())\n ...: \n \n In [15]: msg_loaded\n Out[15]: \n {'code': 0,\n 'data': {'payload': 'yes'},\n 'desc': None,\n 'meta': None,\n 'status': 'S'}\n \n In [16]: msg_loaded.dumps()\n Out[16]: '{\"status\": \"S\", \"code\": 0, \"data\": {\"payload\": \"yes\"}, \"desc\": null, \"meta\": null}'\n \n In [17]: msg_loaded.dumps(skip_none=True)\n Out[17]: '{\"status\": \"S\", \"code\": 0, \"data\": {\"payload\": \"yes\"}}'\n \n In [18]: rspmsg.loads(json.dumps({'status' : 'S', 'code' : 0, 'data' : {'payload' : 'yes'}}))\n Out[18]: \n {'code': 0,\n 'data': {'payload': 'yes'},\n 'desc': None,\n 'meta': None,\n 'status': 'S'}", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/darkdarkfruit/rspmsg", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "rspmsg", "package_url": "https://pypi.org/project/rspmsg/", "platform": "any", "project_url": "https://pypi.org/project/rspmsg/", "project_urls": { "Homepage": "https://github.com/darkdarkfruit/rspmsg" }, "release_url": "https://pypi.org/project/rspmsg/0.6.3/", "requires_dist": null, "requires_python": "", "summary": "A python module for rspmsg", "version": "0.6.3" }, "last_serial": 3496405, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "beeeadb75a6b28840f7a247ab4de3289", "sha256": "b8fece3ee5a14e6fdb122e0eeb3bc21b46953e033f21e90dae83d2d206006d22" }, "downloads": -1, "filename": "rspmsg-0.0.1-py3.6.egg", "has_sig": false, "md5_digest": "beeeadb75a6b28840f7a247ab4de3289", "packagetype": "bdist_egg", "python_version": "3.6", "requires_python": null, "size": 12389, "upload_time": "2018-01-11T07:18:16", "url": "https://files.pythonhosted.org/packages/8f/b6/835430aea72eb185aee20b8b1aeb038d74d8dbcf202f8536161194710ce2/rspmsg-0.0.1-py3.6.egg" }, { "comment_text": "", "digests": { "md5": "35beb79daee8554da5b79fb744266078", "sha256": "d9c50de9463da17b182d5efd6811bc282dcb0b82399001d2b37fac17c6e51677" }, "downloads": -1, "filename": "rspmsg-0.0.1.tar.gz", "has_sig": false, "md5_digest": "35beb79daee8554da5b79fb744266078", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5821, "upload_time": "2018-01-11T05:20:54", "url": "https://files.pythonhosted.org/packages/45/0f/56bc5463ddbc495c56eb3414948851de4a41a7d2e4d30982859c17945ca0/rspmsg-0.0.1.tar.gz" } ], "0.5": [ { "comment_text": "", "digests": { "md5": "9dbbc2dee5a08072e837cbc0cacf54e6", "sha256": "347ed80aba7aa2a0082215f9ca8b98f8c0101677452b94ff24929f757155a381" }, "downloads": -1, "filename": "rspmsg-0.5.tar.gz", "has_sig": false, "md5_digest": "9dbbc2dee5a08072e837cbc0cacf54e6", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6704, "upload_time": "2018-01-11T07:18:25", "url": "https://files.pythonhosted.org/packages/a9/77/3bcfbfddc26bd349234844bebbea56047afdd39ad93db22a743fa70d353a/rspmsg-0.5.tar.gz" } ], "0.6": [ { "comment_text": "", "digests": { "md5": "eeabbf94534ea83aee4ae90fcaac8366", "sha256": "01546ab8e3bbbdd20c66ecb32a5bcac0f32b4a729949cb07001728c56916cd94" }, "downloads": -1, "filename": "rspmsg-0.6.tar.gz", "has_sig": false, "md5_digest": "eeabbf94534ea83aee4ae90fcaac8366", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6194, "upload_time": "2018-01-11T09:26:46", "url": "https://files.pythonhosted.org/packages/fc/3e/a61527b2fd14094bd0c565d77267cace9758c4d82e5b021faa6f5ef7e0f7/rspmsg-0.6.tar.gz" } ], "0.6.1": [ { "comment_text": "", "digests": { "md5": "c42a4683fae7aff67488104b85bc3c9c", "sha256": "38d6b5bbdb8cd3c4fffb04f277167bd99490e0177bd4284c6a83372788f3de22" }, "downloads": -1, "filename": "rspmsg-0.6.1.tar.gz", "has_sig": false, "md5_digest": "c42a4683fae7aff67488104b85bc3c9c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6193, "upload_time": "2018-01-11T09:43:09", "url": "https://files.pythonhosted.org/packages/27/c2/bb721698ade95124781dcd01bc5453db8ef1adf8f015f0c92599ba48de1a/rspmsg-0.6.1.tar.gz" } ], "0.6.2": [ { "comment_text": "", "digests": { "md5": "7b00066679882dbf69fe5100e2ca27f2", "sha256": "26b9a42e9fb6952615390fccef0c026b572ef73ab6810554b090ec9617f0434d" }, "downloads": -1, "filename": "rspmsg-0.6.2.tar.gz", "has_sig": false, "md5_digest": "7b00066679882dbf69fe5100e2ca27f2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6242, "upload_time": "2018-01-11T09:57:41", "url": "https://files.pythonhosted.org/packages/76/a3/b6eab1b63cf1463f14abb23b721350d2deec58f1b998322cecaedc0df280/rspmsg-0.6.2.tar.gz" } ], "0.6.3": [ { "comment_text": "", "digests": { "md5": "5260d12855b6c156f33d16473595dbf0", "sha256": "892471cc0330032fce213cd405d9d67ab103ae736d115cb49f9239645f67c470" }, "downloads": -1, "filename": "rspmsg-0.6.3.tar.gz", "has_sig": false, "md5_digest": "5260d12855b6c156f33d16473595dbf0", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6288, "upload_time": "2018-01-17T07:53:01", "url": "https://files.pythonhosted.org/packages/07/49/de9b51cb274899555c83571e7a7cb63a384d7e37e25ec3055ab57eaa3f28/rspmsg-0.6.3.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "5260d12855b6c156f33d16473595dbf0", "sha256": "892471cc0330032fce213cd405d9d67ab103ae736d115cb49f9239645f67c470" }, "downloads": -1, "filename": "rspmsg-0.6.3.tar.gz", "has_sig": false, "md5_digest": "5260d12855b6c156f33d16473595dbf0", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6288, "upload_time": "2018-01-17T07:53:01", "url": "https://files.pythonhosted.org/packages/07/49/de9b51cb274899555c83571e7a7cb63a384d7e37e25ec3055ab57eaa3f28/rspmsg-0.6.3.tar.gz" } ] }