{ "info": { "author": "Artem Kryvonis", "author_email": "me@kryvonis.com", "bugtrack_url": null, "classifiers": [ "Intended Audience :: Developers", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 2", "Programming Language :: Python :: 3" ], "description": "Released under MIT license\n\n# Description\nThis package provides functionality to work with scheduled tasks (cron-like) in Python.\nThe main intention is to let you use planned scheduled tasks in lazy environments, \nsuch as web server, by providing functions to check previous and next execution time of the task (**get_previous_time** and **get_next_time**).\n\nThis package doesn't parse cron string and is not fully compatible with cron. \nIt currently doesn't support last day of month and last weekday functionality, \nhowever it supports providing the day of week number (#) or providing a week number.\nRules can be provided in a form of list of integers, range object (start, stop, and step will be used), or None.\n\n# Installation\n```\npip install scheduled_task\n```\n\n# Quick start\n#### Task that executes twice a day: at 00:00 and 00:30, get next execution time\n```python\nfrom shceduled_task import ScheduledTask\n\ntask = ScheduledTask(minutes=[0, 30], hours=[0], days=None, months=None, years=None)\nprint(task.get_next_time())\n```\n\n#### Task that executes every 1st day of Month\n```python\nfrom shceduled_task import ScheduledTask\nfrom datetime import datetime\n\ntask = ScheduledTask(minutes=[0], hours=[0], days=[1], months=None, years=None)\nprint(task.get_previous_time(current_datetime=datetime(2016, 11, 19)) \n# Prints datetime(2016, 12, 1, 0, 0))\n```\n\n#### More complex example:\nGet next and previous USA presidential election day by getting the next day after first monday of November every 4rth year\n```python\nfrom scheduled_task import ScheduledTask\n\ntask = ScheduledTask(minutes=[0], hours=[0], days_of_week=[0], days_of_week_num=[0], months=[11], \n years=range(1848, 9999, 4))\nprint(task.get_next_time() + timedelta(days=1))\nprint(task.get_previous_time() + timedelta(days=1))\n```\n\n# Rules\n\n#### Rule types\nWhen creating a ScheduledTask object, you can provide rules of when this task must be executed.\nEvery rule can be of 3 types:\n- **list**: List of values. List can contain 1 value.\n- **range**: Range of values, might contain valid step. For example, day=range(2, 31, 2) means \"every even day of month\".\n- **None**: None means every valid value (* in cron).\n\n#### Rule fields\n| Field | Value | Strategies | Description |\n|------------------|--------|---------------------------------|----------------------------------------------------------------------------------------|\n| minutes | 0-59 | * | Minutes |\n| hours | 0-23 | * | Hours |\n| days | 1-31 | days_of_month | Days |\n| days_of_week | 0-6 | days_of_week, days_of_week_num | Days of week - Monday to Sunday |\n| days_of_week_num | 0-4 | days_of_week_num | Number of day of week. For example, 0 and Friday means every 1st Friday of a month |\n| weeks | 0-5 | days_of_week | Week number. 0 and Friday means every Friday that happens in the first week of a month |\n| months | 1-12 | * | Months |\n| years | 0-9999 | * | Years |\n\n#### Strategies\nWhen creating a ScheduledTask, not all fields are compatible with each other.\nGenerally, there are 3 strategies that will be used:\n- **days_of_month** - default strategy. Used if **days** rule is provided and non of week-related rules are provided. \n- **days_of_week** - this strategy is chosen when **days_of_week** and/or **weeks** rules are provided. If that strategy is chosen, **days** or **days_of_week_num** rules are ignored. \n- **days_of_week_num** - this strategy is chosen when **days_of_week** and **days_of_week_num** rules are provided. This is used to set up rules like \"2nd Monday of July\".\n\n# Providing current time\nWhen calling **get_previous_time** or **get_next_time**, you can provide **current_datetime** to check against. \nIf no current datetime is provided, datetime.utcnow() will be used. \n**current_datetime** doesn't have to be in UTC-format. This library is timezone-agnostic and will return result using the same timezone as current_datetime.\n\n# Contributing\nIf you find a bug in the library, please feel free to contribute by opening an issue or creating a pull request.\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/Kryvonis/scheduled_task", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "scheduled-task", "package_url": "https://pypi.org/project/scheduled-task/", "platform": "", "project_url": "https://pypi.org/project/scheduled-task/", "project_urls": { "Homepage": "https://github.com/Kryvonis/scheduled_task" }, "release_url": "https://pypi.org/project/scheduled-task/1.0.1/", "requires_dist": null, "requires_python": "", "summary": "scheduled tasks for Python 3", "version": "1.0.1" }, "last_serial": 5751966, "releases": { "1.0.0": [ { "comment_text": "", "digests": { "md5": "cacb6c31503f3c3491c82eab34d7734e", "sha256": "621b3f18fdde0fcdd7777db9b4ed87ff624c8a1bf9bb39f09e9e48cc9291b1d4" }, "downloads": -1, "filename": "scheduled_task-1.0.0-py3-none-any.whl", "has_sig": false, "md5_digest": "cacb6c31503f3c3491c82eab34d7734e", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 7924, "upload_time": "2019-08-29T12:15:00", "url": "https://files.pythonhosted.org/packages/6b/27/862f4e15c023c2be2c1e212b17c15c8e1775d132f72cdbc01f1e099cd7cc/scheduled_task-1.0.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "f93fbe0855afadc9d38a9746a8596079", "sha256": "b27e058df3e4b6bf47495a074c747bbdd5720fa2a8f7d696433d1fa47ddbb694" }, "downloads": -1, "filename": "scheduled_task-1.0.0.tar.gz", "has_sig": false, "md5_digest": "f93fbe0855afadc9d38a9746a8596079", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10748, "upload_time": "2019-08-29T12:15:03", "url": "https://files.pythonhosted.org/packages/17/88/db890f89409bb4204785065e7e8a5a821d34be870d10f745cbffe620ac33/scheduled_task-1.0.0.tar.gz" } ], "1.0.1": [ { "comment_text": "", "digests": { "md5": "c66ffc8a64431ce9aeff1459d01f3ef7", "sha256": "9fe613b455c1ab6af23223d46b0477d6dc8fbe9e349283fb5c81333d29c538d9" }, "downloads": -1, "filename": "scheduled_task-1.0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "c66ffc8a64431ce9aeff1459d01f3ef7", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 7923, "upload_time": "2019-08-29T12:19:42", "url": "https://files.pythonhosted.org/packages/7e/1b/6153b312fe85f24fa55a880884179abfd40ae391ab4c68ffbf920cb37884/scheduled_task-1.0.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "8e9b0eecaf55e6a96d8ee96d42233af0", "sha256": "6fa2cd91d32222df01c2f7b97b756c78572f4d4cc118c107ade54e5f5bc0aaec" }, "downloads": -1, "filename": "scheduled_task-1.0.1.tar.gz", "has_sig": false, "md5_digest": "8e9b0eecaf55e6a96d8ee96d42233af0", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10751, "upload_time": "2019-08-29T12:19:43", "url": "https://files.pythonhosted.org/packages/47/f7/a2404a523b7a23008fe466a2554bd114cd6ba8d55a2a7e548bda3818c727/scheduled_task-1.0.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "c66ffc8a64431ce9aeff1459d01f3ef7", "sha256": "9fe613b455c1ab6af23223d46b0477d6dc8fbe9e349283fb5c81333d29c538d9" }, "downloads": -1, "filename": "scheduled_task-1.0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "c66ffc8a64431ce9aeff1459d01f3ef7", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 7923, "upload_time": "2019-08-29T12:19:42", "url": "https://files.pythonhosted.org/packages/7e/1b/6153b312fe85f24fa55a880884179abfd40ae391ab4c68ffbf920cb37884/scheduled_task-1.0.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "8e9b0eecaf55e6a96d8ee96d42233af0", "sha256": "6fa2cd91d32222df01c2f7b97b756c78572f4d4cc118c107ade54e5f5bc0aaec" }, "downloads": -1, "filename": "scheduled_task-1.0.1.tar.gz", "has_sig": false, "md5_digest": "8e9b0eecaf55e6a96d8ee96d42233af0", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10751, "upload_time": "2019-08-29T12:19:43", "url": "https://files.pythonhosted.org/packages/47/f7/a2404a523b7a23008fe466a2554bd114cd6ba8d55a2a7e548bda3818c727/scheduled_task-1.0.1.tar.gz" } ] }