Schedule with Docstrings
Project description
DocCron
Schedule with Docstrings
License | Version | ||
Travis CI | Coverage | ||
AppVeyor | Supported versions | ||
Wheel | Implementation | ||
Status | Downloads | ||
Show your support |
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
- Standard and extended cron formats (see CRON Expression)
- Nonstandard predefined scheduling definitions
- Non-standard characters
- Quartz format
- Works with documentation tools like Sphinx
- Timezone-awareness (CRON_TZ)
TODO
- Human readable date/time strings
References
Author
Project details
Release history Release notifications | RSS feed
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.3.1.tar.gz
(6.6 kB
view hashes)
Built Distribution
Close
Hashes for DocCron-1.3.1-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a621947d6eb0c37d19173a83b28dbf526ae4e92009176d3682468c8b5fdc60e9 |
|
MD5 | 3ba1923d6de48821f190bca2a439f66d |
|
BLAKE2b-256 | a33da08bc2e4f75367cbcb3e66081be83baf90c8497178ae5994c29d17e98872 |