{ "info": { "author": "Anders Borud", "author_email": "", "bugtrack_url": null, "classifiers": [ "Programming Language :: Python", "Topic :: Internet :: WWW/HTTP" ], "description": "# SesamUtils\n\n[![Build Status](https://dev.azure.com/sesam-community/Community%20Python%20Packages/_apis/build/status/sesam-community.sesamutils?branchName=master)](https://dev.azure.com/sesam-community/Community%20Python%20Packages/_build/latest?definitionId=1&branchName=master)\n\n**Python module to simplify common tasks when developing microservices for the Sesam integration platform.**\n\n\n### Usage examples\n\n**Environment Variables**\n\nYou can use the VariablesConfig class to load environment variables into your service. It requires a list of required variables. It also support an optional list of variables as a second argument.\n\n```python\nfrom sesamutils import VariablesConfig\nimport sys\n\nrequired_env_vars = [\"username\", \"password\", \"hostname\"]\noptional_env_vars = [\"debug\", (\"auth_type\", \"user\")] # Default values can be given to optional environment variables by the use of tuples\n\nconfig = VariablesConfig(required_env_vars, optional_env_vars=optional_env_vars)\n\nif not config.validate():\n sys.exit(1)\n\n\nprint(config.username)\n\n```\n\n**Dotdictify**\n\nA class to help traversing and modifying large nested dictionaries. Lets you navigate by dot notation.\n\n```python\nfrom sesamutils import Dotdictify\n\nexample_dict = {\n \"test\": {\n \"my_thing\": \"hello\"\n }\n}\n\ndot_dict = Dotdictify(example_dict)\n\nprint(dot_dict.test.my_thing)\n\n# hello\n\n```\n**Profiler**\n\n You can use this (A profiling decorator) to see complete details of execution time taken by a function in your program. \n Based on that, you can optimize your python code if required.\n\n```python\nfrom sesamutils import profiler\n\n@profiler\ndef ():\n \n\n# Apply to any function with @profiler\n# Profiles the function using cProfile, and prints out a report to screen.\n# belwo are few lines for illustration purpose.\nncalls tottime percall cumtime percall filename:lineno(function)\n1 0.000 0.000 0.312 0.312 C:/Work/PycharmProjects/node-notification-handler/service/notification-handler.py:143(get_node_members_and_roles)\n2 0.000 0.000 0.311 0.156 C:\\Users\\ravish.ranjan\\AppData\\Local\\Programs\\Python\\Python36\\lib\\site-packages\\requests\\sessions.py:537(get)\n2 0.000 0.000 0.311 0.156 C:\\Users\\ravish.ranjan\\AppData\\Local\\Programs\\Python\\Python36\\lib\\site-packages\\requests\\sessions.py:466(request)\n2 0.000 0.000 0.309 0.154 C:\\Users\\ravish.ranjan\\AppData\\Local\\Programs\\Python\\Python36\\lib\\site-packages\\requests\\sessions.py:617(send)\n2 0.000 0.000 0.308 0.154 C:\\Users\\ravish.ranjan\\AppData\\Local\\Programs\\Python\\Python36\\lib\\site-packages\\requests\\adapters.py:394(send)\n2 0.000 0.000 0.306 0.153 C:\\Users\\ravish.ranjan\\AppData\\Local\\Programs\\Python\\Python36\\lib\\site-packages\\urllib3\\connectionpool.py:446(urlopen)\n2 0.000 0.000 0.306 0.153 C:\\Users\\ravish.ranjan\\AppData\\Local\\Programs\\Python\\Python36\\lib\\site-packages\\urllib3\\connectionpool.py:319(_make_request)\n1 0.000 0.000 0.258 0.258 C:\\Work\\PycharmProjects\\node-notification-handler\\service\\portal.py:34(get_subscription_members)\n```\n\n**Sesam Logger**\n\n You can use this to save time and lines of code. It provides the standard customization of root level logging- \n configuration and gives you SESAM uniform standard settings.\n\n```python\nfrom sesamutils import sesam_logger\n\nlogger = sesam_logger('')\n```\n\nDefault log level is 'INFO'. To set a different level, you need to provide the environment variable 'LOG_LEVEL'.\nSince the microservice log view in the Sesam portal gets it's own timestamps directly from docker, this logger does not print timestamps by default.\nHowever if you want to log timestamps regardless, you can enable timestamps like this:\n\n```python\nlogger = sesam_logger('', timestamp=True)\n```\n\nIf your app is using Flask and cherrypy, you can enable request logging by sending the app instance to `sesam_logger` like this:\n\n```python\nlogger = sesam_logger('', app=)\n```\n\n**Serve Flask app**\n\nWhen writing microservices using [Flask](), we don't want to use the built-in development web server as this among other things doesn't set content-length or support chunked encoding (streams).\nTo mitigate this we use cherrypy to serve our Flask microservices. To simplify this task, you can use our `serve` function:\n\n```python\n...\nfrom sesamutils.flask import serve\n\napp = Flask(__name__)\n\n...\n\nif __name__ == \"__main__\":\n serve(app)\n```\nTo define another port than the default (5000), you can do:\n```python\n serve(app, port=)\n```\n\n### Installation\n\n```python\npip install sesamutils\n```\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/sesam-community/", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "sesamutils", "package_url": "https://pypi.org/project/sesamutils/", "platform": "", "project_url": "https://pypi.org/project/sesamutils/", "project_urls": { "Homepage": "https://github.com/sesam-community/" }, "release_url": "https://pypi.org/project/sesamutils/0.1.10/", "requires_dist": [ "pytest", "testfixtures", "paste", "CherryPy (==18.2.0)" ], "requires_python": "", "summary": "Sesam microservice utils", "version": "0.1.10" }, "last_serial": 5920216, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "73e01a9687c886bcd60e96ca5e5ca1bb", "sha256": "4b4608af20308ca6c540ac17db40dd912e027c2dec62bc162d86ef7ab8fe12b7" }, "downloads": -1, "filename": "sesamutils-0.1.0-py3-none-any.whl", "has_sig": false, "md5_digest": "73e01a9687c886bcd60e96ca5e5ca1bb", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 6047, "upload_time": "2019-08-13T07:17:51", "url": "https://files.pythonhosted.org/packages/a3/1b/ebfc646a9e1224bd1f45d1ed6b481d2c8710e084801c84b7c65e8c4a3198/sesamutils-0.1.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "fcfa104687c6aea3f41754d17fbadf7e", "sha256": "885ef60ff97bad822c56a049234c3c52e139e74f6e72f70a846ce64bc557ce35" }, "downloads": -1, "filename": "sesamutils-0.1.0.tar.gz", "has_sig": false, "md5_digest": "fcfa104687c6aea3f41754d17fbadf7e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 1501, "upload_time": "2019-08-13T07:17:53", "url": "https://files.pythonhosted.org/packages/c7/24/893ef4ba55f58eb7568b85df5828c05cbebc0cc534ed483a23362ed1f737/sesamutils-0.1.0.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "614a5a6bd7822d9826e8af904f0e1fc7", "sha256": "e37838308902a0240316a03768e3cab429f184e5aac89d11f0d7b78dc585269f" }, "downloads": -1, "filename": "sesamutils-0.1.1-py3-none-any.whl", "has_sig": false, "md5_digest": "614a5a6bd7822d9826e8af904f0e1fc7", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 6060, "upload_time": "2019-08-13T07:28:20", "url": "https://files.pythonhosted.org/packages/38/0d/5f14872f8148153b1cc07a4485397df250850b2efc5dd44f16e5351aec82/sesamutils-0.1.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "f27a5f0a3d6c05f0739284b37a2c265f", "sha256": "9d4c586aa37f81001b057203385481b92f508616e3987c3ac71b132e96ce641b" }, "downloads": -1, "filename": "sesamutils-0.1.1.tar.gz", "has_sig": false, "md5_digest": "f27a5f0a3d6c05f0739284b37a2c265f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 1496, "upload_time": "2019-08-13T07:28:21", "url": "https://files.pythonhosted.org/packages/2f/90/bdacf5823803d44d8efb5eed38a76dd6199b182ab5b6956d80513068d2aa/sesamutils-0.1.1.tar.gz" } ], "0.1.10": [ { "comment_text": "", "digests": { "md5": "894c773e99f72a0b4a659601219d9c66", "sha256": "b58edc36604f91acb47eb424ceb4ea9513eccf2dd37e511b84cda8492498d93a" }, "downloads": -1, "filename": "sesamutils-0.1.10-py3-none-any.whl", "has_sig": false, "md5_digest": "894c773e99f72a0b4a659601219d9c66", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 12099, "upload_time": "2019-10-02T19:50:05", "url": "https://files.pythonhosted.org/packages/a5/ca/856764bdb6bc845ad9879440a1528f92e924684a12506da3d4fc050e017d/sesamutils-0.1.10-py3-none-any.whl" } ], "0.1.2": [ { "comment_text": "", "digests": { "md5": "f361184070cfc6f7664449668270c11e", "sha256": "dc2dbbed4729062c07a2bb1fa0affc8d1c8d83e5ecb2d815b5f317b1f8ac7b64" }, "downloads": -1, "filename": "sesamutils-0.1.2-py3-none-any.whl", "has_sig": false, "md5_digest": "f361184070cfc6f7664449668270c11e", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 6208, "upload_time": "2019-08-13T07:49:51", "url": "https://files.pythonhosted.org/packages/ab/10/db1e24141f70530ea632e46937fad15dbe6bf0d8a0577f5dd530eb932b0e/sesamutils-0.1.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "b399ac77c35c2b4637898f2b9840368e", "sha256": "1b943bddad40c8720c7841418ac8edd9e360b91f51765c64f41399becdd8c436" }, "downloads": -1, "filename": "sesamutils-0.1.2.tar.gz", "has_sig": false, "md5_digest": "b399ac77c35c2b4637898f2b9840368e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 1660, "upload_time": "2019-08-13T07:49:52", "url": "https://files.pythonhosted.org/packages/c4/f6/78d9c680c6cd032ac4a5d8b3e35ee0487d5db433fae3448fd8721dfb7549/sesamutils-0.1.2.tar.gz" } ], "0.1.3": [ { "comment_text": "", "digests": { "md5": "072c7da29eab7de5d124c28d7bae32f6", "sha256": "2f827ddc76d51970999e6c986b9f39c61534c3107b6eb1330e19132735510e50" }, "downloads": -1, "filename": "sesamutils-0.1.3-py3-none-any.whl", "has_sig": false, "md5_digest": "072c7da29eab7de5d124c28d7bae32f6", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 7216, "upload_time": "2019-08-15T10:04:36", "url": "https://files.pythonhosted.org/packages/42/12/79e2fc69ff15c6e09e8edd23c044e5beade95ba2307550680eece6b174a2/sesamutils-0.1.3-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "631077e310089e63ef5bc85ec9c14395", "sha256": "dbf336aa2abe015a5d59f1fea2dfaa5b3b6218113425301f935b926dac0a61ef" }, "downloads": -1, "filename": "sesamutils-0.1.3.tar.gz", "has_sig": false, "md5_digest": "631077e310089e63ef5bc85ec9c14395", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2446, "upload_time": "2019-08-15T10:04:38", "url": "https://files.pythonhosted.org/packages/8f/17/d5b7622904b65160f68979af82dd33e7990c5f992367c12a960e8a478e1e/sesamutils-0.1.3.tar.gz" } ], "0.1.4": [ { "comment_text": "", "digests": { "md5": "c6c8c340cf06679a21ad7fd720d68bea", "sha256": "a55f559d2ca98c13a761f510c87f3aa91fdcc1224415c0257fbae4da84aaae06" }, "downloads": -1, "filename": "sesamutils-0.1.4-py3-none-any.whl", "has_sig": false, "md5_digest": "c6c8c340cf06679a21ad7fd720d68bea", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 9021, "upload_time": "2019-09-06T08:08:20", "url": "https://files.pythonhosted.org/packages/6d/c6/d0d1d9565c58e0a7463d87b6518f69b2eda780eaed645733d10cac5ea72b/sesamutils-0.1.4-py3-none-any.whl" } ], "0.1.5": [ { "comment_text": "", "digests": { "md5": "87a573e57c77b139f820eaf46404e4db", "sha256": "ba6f8518a61a85040da2b11e6f13b9c012badf9ccc7b1b98448666ea013dbd2c" }, "downloads": -1, "filename": "sesamutils-0.1.5-py3-none-any.whl", "has_sig": false, "md5_digest": "87a573e57c77b139f820eaf46404e4db", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 9252, "upload_time": "2019-09-06T11:21:20", "url": "https://files.pythonhosted.org/packages/fc/a1/46d2d7a96a07e4c439a011d4935581f4e82532607f058acbb5a60d2f856d/sesamutils-0.1.5-py3-none-any.whl" } ], "0.1.6": [ { "comment_text": "", "digests": { "md5": "c73c993476c9df8297c1d6670cc182ea", "sha256": "ebc347c6305add747ca9bb0449d7a9331facc208ed3a25bb9e1cc3ab7b3cc448" }, "downloads": -1, "filename": "sesamutils-0.1.6-py3-none-any.whl", "has_sig": false, "md5_digest": "c73c993476c9df8297c1d6670cc182ea", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 10365, "upload_time": "2019-09-09T08:45:58", "url": "https://files.pythonhosted.org/packages/74/b8/d3a8d4db87987b87b7ea73442926f88e6b8ca3c6eb688063b95201892a2c/sesamutils-0.1.6-py3-none-any.whl" } ], "0.1.7": [ { "comment_text": "", "digests": { "md5": "431fa8ecba7369ec6f04488969fdbf33", "sha256": "e52fa8e52a15adb88e866e5519d35dab8d0654b6fdb14fe9e603dcf0b938c9e5" }, "downloads": -1, "filename": "sesamutils-0.1.7-py3-none-any.whl", "has_sig": false, "md5_digest": "431fa8ecba7369ec6f04488969fdbf33", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 11089, "upload_time": "2019-09-20T08:22:34", "url": "https://files.pythonhosted.org/packages/af/c1/f0034b4dc4c6d4198429088851015a3f181512f884f0d2ed6d87c466f6e8/sesamutils-0.1.7-py3-none-any.whl" } ], "0.1.8": [ { "comment_text": "", "digests": { "md5": "602989ac263eb3f6dedcbcc9c6e2364f", "sha256": "199cb499ba23290f27a719d31839d2c9af9de51bb3c2684a7a6f7c3f62778cda" }, "downloads": -1, "filename": "sesamutils-0.1.8-py3-none-any.whl", "has_sig": false, "md5_digest": "602989ac263eb3f6dedcbcc9c6e2364f", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 11324, "upload_time": "2019-09-30T11:40:12", "url": "https://files.pythonhosted.org/packages/8f/32/a12a3c705b8a9da4cde9398391afbace879a19a7637d95d4916af6cff2d1/sesamutils-0.1.8-py3-none-any.whl" } ], "0.1.9": [ { "comment_text": "", "digests": { "md5": "2fb6b7d61d058a32f9ee05077ff37b6f", "sha256": "92c3787e922a73396b8715034fd040da6de2ce2490e5470ac7b002cb7bc5f6b8" }, "downloads": -1, "filename": "sesamutils-0.1.9-py3-none-any.whl", "has_sig": false, "md5_digest": "2fb6b7d61d058a32f9ee05077ff37b6f", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 12008, "upload_time": "2019-09-30T12:19:02", "url": "https://files.pythonhosted.org/packages/12/a4/346e60a6ace04324aac03ac3c0f7a199e59c1964b7350ad9743cad402f04/sesamutils-0.1.9-py3-none-any.whl" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "894c773e99f72a0b4a659601219d9c66", "sha256": "b58edc36604f91acb47eb424ceb4ea9513eccf2dd37e511b84cda8492498d93a" }, "downloads": -1, "filename": "sesamutils-0.1.10-py3-none-any.whl", "has_sig": false, "md5_digest": "894c773e99f72a0b4a659601219d9c66", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 12099, "upload_time": "2019-10-02T19:50:05", "url": "https://files.pythonhosted.org/packages/a5/ca/856764bdb6bc845ad9879440a1528f92e924684a12506da3d4fc050e017d/sesamutils-0.1.10-py3-none-any.whl" } ] }