Name | cronevents JSON |
Version |
0.0.31
JSON |
| download |
home_page | None |
Summary | A package to run cron jobs(events) |
upload_time | 2024-09-13 02:06:41 |
maintainer | None |
docs_url | None |
author | Daniel Olson |
requires_python | >=3.10 |
license | None |
keywords |
cron
jobs
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# Cron Events
This module provides a way to schedule recurring events using a cron-like syntax.
Events can be scheduled to run at specific intervals or at specific times on specific days.
## Table of Contents
<!--
- [Features](#features)
-->
- [Installation](#installation) <!-- - [Quick Start](#quick-start) -->
- [Learn by Example](#example)
- [License](#license)
## Installation
`pip install cronevents`
[//]: # (## Quick Start)
[//]: # (1. Get example template: `bue example` (warning: this command will over-write `.env`))
[//]: # (2. Start Bucket server, Hub and 3 workers: `bue demo`)
[//]: # (3. Upload script and wait for results: `python3 example.py`)
## Learn by Example
```python
"""Cron-like event scheduling module.
This module provides a way to schedule recurring events using a cron-like syntax.
Events can be scheduled to run at specific intervals or at specific times on specific days.
Syntax:
'every (`Weekday` or `n unit`) [@ hh[:mm[:ss]] ["am" or "pm"]]'
Examples:
'every 2 days @ 10:00:00 pm'
'every Monday @ 23'
'every 5 seconds'
Note:
Using '@' will run the event at least once a day.
"""
# Uncomment to register events to the event manager
# import os
# os.environ['REGISTER_CRON_EVENT'] = 'true'
from cronevents.event_manager import event
@event('every 31 seconds')
def test():
"""Write 'test' to a file and print it every 31 seconds."""
with open('test.txt', 'a') as f:
f.write('test\n')
print('test')
@event('every 2 days 1 hours 23 minutes 2 seconds')
def test2():
"""Write 'test2' to a file and print 'test2' every 2 days, 1 hour, 23 minutes, and 2 seconds."""
with open('test.txt', 'a') as f:
f.write('test2\n')
print('test2')
@event('every 1 days @ 2:00 pm')
def test3():
"""Write 'test3' to a file and print it daily at 2:00 PM."""
with open('test.txt', 'a') as f:
f.write('test3\n')
print('test3')
@event('every Friday')
def test4():
"""Write 'test4' to a file and print it every Friday."""
with open('test.txt', 'a') as f:
f.write('test4\n')
print('test4')
@event('every Tuesday @ 3:00')
def test5():
"""Write 'test5' to a file and print it every Tuesday at 3:00 AM."""
with open('test.txt', 'a') as f:
f.write('test5\n')
print('test5')
```
## License
* MIT License
Raw data
{
"_id": null,
"home_page": null,
"name": "cronevents",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.10",
"maintainer_email": null,
"keywords": "cron jobs",
"author": "Daniel Olson",
"author_email": "daniel@orphos.cloud",
"download_url": "https://files.pythonhosted.org/packages/20/0c/45f01beafe5e5ceadc1a7796e8b46318476e3bfd60c7072e522fd5e48fbe/cronevents-0.0.31.tar.gz",
"platform": null,
"description": "# Cron Events\n\nThis module provides a way to schedule recurring events using a cron-like syntax.\nEvents can be scheduled to run at specific intervals or at specific times on specific days.\n\n\n## Table of Contents\n<!--\n- [Features](#features)\n-->\n- [Installation](#installation) <!-- - [Quick Start](#quick-start) -->\n- [Learn by Example](#example) \n- [License](#license)\n\n## Installation\n\n`pip install cronevents`\n\n\n[//]: # (## Quick Start)\n\n[//]: # (1. Get example template: `bue example` (warning: this command will over-write `.env`))\n\n[//]: # (2. Start Bucket server, Hub and 3 workers: `bue demo`)\n\n[//]: # (3. Upload script and wait for results: `python3 example.py`)\n\n\n## Learn by Example\n\n```python\n\"\"\"Cron-like event scheduling module.\n\nThis module provides a way to schedule recurring events using a cron-like syntax.\nEvents can be scheduled to run at specific intervals or at specific times on specific days.\n\nSyntax:\n 'every (`Weekday` or `n unit`) [@ hh[:mm[:ss]] [\"am\" or \"pm\"]]'\n\nExamples:\n 'every 2 days @ 10:00:00 pm'\n 'every Monday @ 23'\n 'every 5 seconds'\n\nNote:\n Using '@' will run the event at least once a day.\n\"\"\"\n\n# Uncomment to register events to the event manager\n# import os\n# os.environ['REGISTER_CRON_EVENT'] = 'true'\n\nfrom cronevents.event_manager import event\n\n\n@event('every 31 seconds')\ndef test():\n \"\"\"Write 'test' to a file and print it every 31 seconds.\"\"\"\n with open('test.txt', 'a') as f:\n f.write('test\\n')\n print('test')\n\n\n@event('every 2 days 1 hours 23 minutes 2 seconds')\ndef test2():\n \"\"\"Write 'test2' to a file and print 'test2' every 2 days, 1 hour, 23 minutes, and 2 seconds.\"\"\"\n with open('test.txt', 'a') as f:\n f.write('test2\\n')\n print('test2')\n\n\n@event('every 1 days @ 2:00 pm')\ndef test3():\n \"\"\"Write 'test3' to a file and print it daily at 2:00 PM.\"\"\"\n with open('test.txt', 'a') as f:\n f.write('test3\\n')\n print('test3')\n\n\n@event('every Friday')\ndef test4():\n \"\"\"Write 'test4' to a file and print it every Friday.\"\"\"\n with open('test.txt', 'a') as f:\n f.write('test4\\n')\n print('test4')\n\n\n@event('every Tuesday @ 3:00')\ndef test5():\n \"\"\"Write 'test5' to a file and print it every Tuesday at 3:00 AM.\"\"\"\n with open('test.txt', 'a') as f:\n f.write('test5\\n')\n print('test5')\n```\n\n## License\n* MIT License\n",
"bugtrack_url": null,
"license": null,
"summary": "A package to run cron jobs(events)",
"version": "0.0.31",
"project_urls": null,
"split_keywords": [
"cron",
"jobs"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "68407c00c4faf8a346d810f650a34857bdb0362bf7048cabed2e4f4d574367cd",
"md5": "9ee89749683b4351b199de15927a5e9f",
"sha256": "4d94e462bc4358098c9c9352c096b447cc737da3f4af009e6cd49fe72ec1b610"
},
"downloads": -1,
"filename": "cronevents-0.0.31-py3-none-any.whl",
"has_sig": false,
"md5_digest": "9ee89749683b4351b199de15927a5e9f",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.10",
"size": 10564,
"upload_time": "2024-09-13T02:06:40",
"upload_time_iso_8601": "2024-09-13T02:06:40.586187Z",
"url": "https://files.pythonhosted.org/packages/68/40/7c00c4faf8a346d810f650a34857bdb0362bf7048cabed2e4f4d574367cd/cronevents-0.0.31-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "200c45f01beafe5e5ceadc1a7796e8b46318476e3bfd60c7072e522fd5e48fbe",
"md5": "906803e81efeeb211183fbec5a55cbc5",
"sha256": "f0bbeaf91fc2a27a4091927115232c9bb0fb831f353b7017aa92624805d65410"
},
"downloads": -1,
"filename": "cronevents-0.0.31.tar.gz",
"has_sig": false,
"md5_digest": "906803e81efeeb211183fbec5a55cbc5",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10",
"size": 10416,
"upload_time": "2024-09-13T02:06:41",
"upload_time_iso_8601": "2024-09-13T02:06:41.923412Z",
"url": "https://files.pythonhosted.org/packages/20/0c/45f01beafe5e5ceadc1a7796e8b46318476e3bfd60c7072e522fd5e48fbe/cronevents-0.0.31.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-09-13 02:06:41",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "cronevents"
}