Skip to main content

Schedule with Docstrings

Project description

DocCron

Schedule with Docstrings

License License Version Version
Travis CI Travis CI Coverage CodeCov
AppVeyor AppVeyor Supported versions Python Versions
Wheel Wheel Implementation Implementation
Status Status Downloads Downloads

Installation

pip install DocCron

Description

Cron-based scheduler inspired by doctest

Example

Cron jobs can be embedded into docstrings by using a literal block (::). Literal blocks should start with /etc/crontab.

Standard/Extended Format

Run hello() at every 2nd minute and 3rd minute:

import time


def hello():
    """
    Print "hello world" at every 2nd minute and 3rd minute:

    /etc/crontab::

        */2 * * * *
        */3 * * * *
    """
    print(time.strftime('%Y-%m-%d %H:%M:%S'), "hello world")


if __name__ == '__main__':
    import doccron
    doccron.run_jobs()

Quartz Format

Run hello() at every 2nd second and 3rd second:

import time


def hello():
    """
    Print "hello world" every 2nd second and 3rd second:

    /etc/crontab::

        */2 * * * * *
        */3 * * * * *
    """
    print(time.strftime('%Y-%m-%d %H:%M:%S'), "hello world")


if __name__ == '__main__':
    import doccron
    doccron.run_jobs(quartz=True)

Timezone-Awareness (CRON_TZ)

DocCron now support CRON_TZ. The value of CRON_TZ only applies to succeeding cron jobs. DocCron supports multiple CRON_TZ in a cron table. The default timezone value is the local/system timezone, if not specified.

import time


def hello():
    """
    Print "hello world" at every 2nd minute and 3rd minute:

    /etc/crontab::
    
        CRON_TZ=UTC
        */2 * * * *
        */3 * * * *
    """
    print(time.strftime('%Y-%m-%d %H:%M:%S%z'), "hello world")


if __name__ == '__main__':
    import doccron
    doccron.run_jobs()

Features

TODO

  • Human readable date/time strings

References

Author

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

doccron-1.4.1.tar.gz (8.7 kB view hashes)

Uploaded Source

Built Distribution

doccron-1.4.1-py3-none-any.whl (8.4 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page