cronevents


Namecronevents JSON
Version 0.0.35 PyPI version JSON
download
home_pageNone
SummaryA package to run cron jobs(events)
upload_time2024-12-20 18:52:20
maintainerNone
docs_urlNone
authorDaniel Olson
requires_python>=3.10
licenseNone
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` &#40;warning: this command will over-write `.env`&#41;)

[//]: # (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/c6/e4/d7975dd47f22246bfcc0ac95c1404485c111fe310361e84ae761495cb8e6/cronevents-0.0.35.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` &#40;warning: this command will over-write `.env`&#41;)\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.35",
    "project_urls": null,
    "split_keywords": [
        "cron",
        "jobs"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e22dc4d26b2fcc1c6013b0531877a6cc1617a3135c0bb27744cd0d0fbc4bbb5a",
                "md5": "994c676788dfc0aed333fbdc49a0af3e",
                "sha256": "3c167059e8b84452b1c84671ffa01ee556cb27984c4f9a7de58bf7742237d61e"
            },
            "downloads": -1,
            "filename": "cronevents-0.0.35-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "994c676788dfc0aed333fbdc49a0af3e",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 12608,
            "upload_time": "2024-12-20T18:52:18",
            "upload_time_iso_8601": "2024-12-20T18:52:18.431593Z",
            "url": "https://files.pythonhosted.org/packages/e2/2d/c4d26b2fcc1c6013b0531877a6cc1617a3135c0bb27744cd0d0fbc4bbb5a/cronevents-0.0.35-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c6e4d7975dd47f22246bfcc0ac95c1404485c111fe310361e84ae761495cb8e6",
                "md5": "53e5c73786401b19752c4e5c6640612d",
                "sha256": "15e94df0849c48814ae103fb18c193a11f242f8f0bdfac0ca03299785ca38a8a"
            },
            "downloads": -1,
            "filename": "cronevents-0.0.35.tar.gz",
            "has_sig": false,
            "md5_digest": "53e5c73786401b19752c4e5c6640612d",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 12186,
            "upload_time": "2024-12-20T18:52:20",
            "upload_time_iso_8601": "2024-12-20T18:52:20.666051Z",
            "url": "https://files.pythonhosted.org/packages/c6/e4/d7975dd47f22246bfcc0ac95c1404485c111fe310361e84ae761495cb8e6/cronevents-0.0.35.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-12-20 18:52:20",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "cronevents"
}
        
Elapsed time: 2.53257s