{ "info": { "author": "Alexander Maretskiy", "author_email": "amaretskiy@mirantis.com", "bugtrack_url": null, "classifiers": [ "Intended Audience :: Developers", "License :: OSI Approved :: Apache Software License", "Operating System :: POSIX :: Linux", "Programming Language :: Python", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5" ], "description": "Mirantis OSS Tooling Library\n============================\n\nA library which contains various functions and classes which help to build\nunified OSS Tools services.\n\nConfiguration and Logging\n-------------------------\n\n``oss_lib.config`` a module for finding configuration files, parsing them and\nvalidating.\n\nLocation of Configuration\n~~~~~~~~~~~~~~~~~~~~~~~~~\n\n``oss_lib.config`` provides two functions, such as ``process_args`` and\n``process_env``, to find a configuration file and use it as a source of\nsettings.\n\nThe ``process_args`` function accepts arguments from the command line at first\npriority. If some of them are not specified, then suitable environment\nvariables are used, otherwise the default values are used.\n\nThe ``process_env`` gets environment variables, otherwise default values are\nused.\n\nTwo of these functions accept the first position argument which is used as\na prefix for environment variables, e.g. if ``\"CEAGLE\"`` was specified, then\n``CEAGLE_CONF`` will be expected as an environment variable.\n\nThe full list of supported command line arguments and environment variables:\n\n================= ==================== ======= =====================================\nArgument Environment variable Default Description\n================= ==================== ======= =====================================\n--debug _DEBUG false Use DEBUG instead of INFO for\n logging, possible values true/false.\n--config-file _CONF Path to a YAML-configuration file.\n--log-config-file _LOG_CONF Path to a file with configuration for\n `Python logging module`_\n================= ==================== ======= =====================================\n\n.. _Python logging module: https://docs.python.org/3/library/logging.config.html#configuration-file-format\n\nBoth functions support the default location of a configuration file in case if\nit was not specified through ``--config-file`` or ``_CONF``.\nThe default location can be set using the ``default_config_path`` parameter and\nit will be used only if this file exists.\n\nThe list of examples to understand priorities how a configuration file is\nchoosen:\n\n================ ================ =================== =================\n--config-file _CONF default_config_path Result\n================ ================ =================== =================\n/etc/ceagle.yaml /etc/config.yaml /etc/default.yaml /etc/ceagle.yaml\n /etc/config.yaml /etc/default.yaml /etc/config.yaml\n /etc/default.yaml /etc/default.yaml\n (exists)\n /etc/default.yaml \n (does not exist)\n================ ================ =================== =================\n\nValidation and Defaults\n~~~~~~~~~~~~~~~~~~~~~~~\n\nBy default ``oss_lib.config`` expects that all configuration settings pass\nthrough validation in the JSON Schema-like format.\nThe ``validation_schema`` parameter expects a dict which populates only\nthe ``properties`` parameter in the schema. For example, if your application\nexpects two top defined parameters in :\n\n.. code-block:: python\n\n SCHEMA = {\n \"elasticsearch\": {\n \"type\": \"object\",\n \"properties\": {\n \"hosts\": {\n \"type\": \"array\",\n \"minItems\": 1,\n \"uniqueItems\": True,\n \"items\": {\n \"type\": \"object\",\n \"properties\": {\n \"host\": {\"type\": \"string\"},\n \"port\": {\"type\": \"integer\"},\n },\n \"required\": [\"host\"],\n \"additionalProperties\": False,\n },\n },\n },\n \"required\": [\"hosts\"],\n \"additionalProperties\": False,\n },\n \"config\": {\n \"type\": \"object\",\n \"properties\": {\n \"run_every_minutes\": {\n \"type\": \"integer\",\n \"minimum\": 1,\n },\n },\n \"required\": [\"run_every_minutes\"],\n \"additionalProperties\": False,\n },\n }\n\n config.process_env(...,\n validation_schema=SCHEMA,\n ....)\n\nThe default values for settings can be also specified through the ``defaults``\nparameter, e.g.:\n\n.. code-block:: python\n\n DEFAULTS = {\n \"elasticsearch\": {\"hosts\": [\n {\"host\": \"127.0.0.1\", \"port\": 9200},\n ]},\n \"config\": {\"run_every_minutes\": 2},\n }\n\n config.process_env(...,\n validation_schema=SCHEMA,\n defaults=DEFAULTS,\n ....)\n\nIf defaults are specified, then they will be used as settings and\nloaded settings from specified configuration files will be merged into them.\nFor example, if the configuration file contains:\n\n.. code-block::\n\n elasticsearch:\n hosts:\n - host: 172.16.169.4\n port: 9200\n\nThe resulting config will look like that:\n\n.. code-block:: python\n\n {\n \"elasticsearch\": {\n \"hosts\": [\n {\"host\": \"172.16.169.4\", \"port\": 9200},\n ],\n },\n \"config\": {\"run_every_minutes\": 2},\n }\n\nIt means that only dictionary values are merged but primitives are just\nreplaced.\n\nUsage Examples\n~~~~~~~~~~~~~~\n\nAfter initialization of configuration ``oss_lib.config`` module provides\na single tone object to interect with configuration settings. This object can\nbe accessed through the ``oss_lib.config.CONF`` variables in a dict-like way.\n\nLet's take a look on the example how to initialize configuration accepting\ncommand line arguments and environment variables ``example.py``:\n\n.. code-block:: python\n\n from oss_lib import config\n\n SCHEMA = {\n \"driver\": {\"enum\": [\"noop\", \"openstack\"]},\n }\n\n DEFAULTS = {\n \"driver\": \"noop\",\n }\n\n config.process_args(\"CEAGLE\",\n default_config_path=\"/etc/default.yaml\",\n validation_schema=SCHEMA,\n defaults=DEFAULTS)\n print(config.CONF[\"driver\"])\n\nSo, after that you can run your application in various ways using:\n\n#. The command line argument ``--config-file``:\n\n.. code-block:: sh\n\n echo \"driver: openstack\" > /etc/ceagle.yaml\n python example.py --config-file /etc/ceagle.yaml #-> openstack\n\n#. The environment variable ``CEAGLE_CONF``:\n\n.. code-block:: sh\n\n CEAGLE_CONF=/etc/ceagle.yaml\n echo \"driver: openstack\" > $CEAGLE_CONF\n python example.py #-> openstack\n\n#. Or without any variables because the ``default_config_path`` parameter was\n specified:\n\n.. code-block:: sh\n\n echo \"driver: openstack\" > /etc/default.yaml\n python example.py #-> openstack\n\n#. Or even you can specify nothing because the ``defaults`` parameter was set:\n\n.. code-block:: sh\n\n python example.py #-> noop\n\n\nUseful Stuff for Flask\n----------------------\n\nrouting.py\n~~~~~~~~~~\n\nRouting stuff like auto-generated HTML and JSON pages\nwith map of routes. This is useful for development\nprocess and for exposing APIs.\n\nExample:\n\n.. code-block:: python\n\n from oss_lib import routing\n ...\n\n app = Flask(...)\n ...\n app.add_url_rule(...) # add routes\n ...\n\n # Now add routing map pages\n app = routing.add_routing_map(app,\n html_uri=\"/api.html\",\n json_uri=\"/api.json\")\n\n\nNow run the application and find auto-generated pages\non given URIs */api.html* and */api.json*\n", "description_content_type": null, "docs_url": null, "download_url": null, "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/seecloud/oss-lib", "keywords": null, "license": "Apache 2.0", "maintainer": null, "maintainer_email": null, "name": "oss-lib", "package_url": "https://pypi.org/project/oss-lib/", "platform": "any", "project_url": "https://pypi.org/project/oss-lib/", "project_urls": { "Homepage": "https://github.com/seecloud/oss-lib" }, "release_url": "https://pypi.org/project/oss-lib/0.1.1/", "requires_dist": null, "requires_python": null, "summary": "OSS Tooling Library", "version": "0.1.1" }, "last_serial": 2537435, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "e9885b728108a57141ca3cedc37a3d3b", "sha256": "ce7d16290fb66a6c992bf518da8ac52ed167ae5c2d03471a5105320f08094ce4" }, "downloads": -1, "filename": "oss_lib-0.1.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "e9885b728108a57141ca3cedc37a3d3b", "packagetype": "bdist_wheel", "python_version": "any", "requires_python": null, "size": 4427, "upload_time": "2016-12-14T15:45:27", "url": "https://files.pythonhosted.org/packages/7a/99/b2695b150f21c986fea6b259420f98c4604cb0d4b2c582b8e33a892e729d/oss_lib-0.1.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "f0e331780c33f531532d7b77fa7032f7", "sha256": "df544542d399fd2690d829a0819ddfc3e9f212c172cd05b7f94adec468190e03" }, "downloads": -1, "filename": "oss_lib-0.1.0.tar.gz", "has_sig": false, "md5_digest": "f0e331780c33f531532d7b77fa7032f7", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3152, "upload_time": "2016-12-14T15:43:43", "url": "https://files.pythonhosted.org/packages/c2/61/36d8f97ff58ad0a3861e31795c912dc9d3fbf3fe39c0a965c7aeca3cc6e3/oss_lib-0.1.0.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "5bd1fa0b71feaddc13cc81c24511c520", "sha256": "e6b0e5d9053f8e4066d93d438150da38b0e42680276030761ea36dee3e85eb7c" }, "downloads": -1, "filename": "oss_lib-0.1.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "5bd1fa0b71feaddc13cc81c24511c520", "packagetype": "bdist_wheel", "python_version": "any", "requires_python": null, "size": 6411, "upload_time": "2016-12-23T22:34:37", "url": "https://files.pythonhosted.org/packages/50/e4/c91850f148276f65e9cb7e4e1aab75048c12dc5ae31d2282532c031ac6ba/oss_lib-0.1.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "513c4fc2329b6a370a163fdd3874f8b9", "sha256": "87293ffd224c7d50df7b01d5f5606fa684c7f420ec9fc6f6304da5062221f9c5" }, "downloads": -1, "filename": "oss_lib-0.1.1.tar.gz", "has_sig": false, "md5_digest": "513c4fc2329b6a370a163fdd3874f8b9", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6593, "upload_time": "2016-12-23T22:34:20", "url": "https://files.pythonhosted.org/packages/7a/e4/6020a26180df6cc2f61185fcaea3708164c1b21dd78459cd10c170e108ae/oss_lib-0.1.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "5bd1fa0b71feaddc13cc81c24511c520", "sha256": "e6b0e5d9053f8e4066d93d438150da38b0e42680276030761ea36dee3e85eb7c" }, "downloads": -1, "filename": "oss_lib-0.1.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "5bd1fa0b71feaddc13cc81c24511c520", "packagetype": "bdist_wheel", "python_version": "any", "requires_python": null, "size": 6411, "upload_time": "2016-12-23T22:34:37", "url": "https://files.pythonhosted.org/packages/50/e4/c91850f148276f65e9cb7e4e1aab75048c12dc5ae31d2282532c031ac6ba/oss_lib-0.1.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "513c4fc2329b6a370a163fdd3874f8b9", "sha256": "87293ffd224c7d50df7b01d5f5606fa684c7f420ec9fc6f6304da5062221f9c5" }, "downloads": -1, "filename": "oss_lib-0.1.1.tar.gz", "has_sig": false, "md5_digest": "513c4fc2329b6a370a163fdd3874f8b9", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6593, "upload_time": "2016-12-23T22:34:20", "url": "https://files.pythonhosted.org/packages/7a/e4/6020a26180df6cc2f61185fcaea3708164c1b21dd78459cd10c170e108ae/oss_lib-0.1.1.tar.gz" } ] }