Cron Schedule Triggers ~ A library for determining Quartz Cron schedule trigger dates.
Project description
CronScheduleTriggers: Quartz Syntax based Cron Trigger library.
Cron Schedule Triggers (CSTriggers) is a Python library enabling the ability to determine the next execution of a live schedule. Its syntax is that of Quartz Job Scheduler. This library is not a scheduling app or a task queue, there are plenty of those in the wild to choose from. When you need advanced customisation of triggers for tasks, and a common and conventional syntax for schedule notation, CSTriggers comes to your aid.
This library is for those who
- Want the ability to generate future task data for visualization purposes.
- Want to combine their own choice of solutions to build a customizable integrated task queuing/scheduling system at any scale.
- Do not want to run java, but want to take advantage of the rich Quartz Cron syntax
- Do not want to drag in many dependencies into their project (Uses standard Python3 libraries only).
Example usage
Initialize a schedule object with a cron notation string, a start date, and an optional end date. Call .next_trigger()
for a new date.
from cstriggers.core.trigger import QuartzCron
schedule_string = "0 0 0 1 JAN-MAR ? 2010-2015"
start_date = "2019-10-13T00:00:00"
end_date = "2022-10-13T00:00:00"
cron_obj = QuartzCron(schedule_string=schedule_string, start_date=start_date, end_date=end_date)
print(cron_obj.next_trigger(isoformat=True))
>> 2020-01-01T00:00:00
For multiple sequential dates call either .next_trigger()
multiple times
from cstriggers.core.trigger import QuartzCron
schedule_string = "0 0 0 1 JAN-MAR ? 2010-2030"
start_date = "2019-10-13T00:00:00"
end_date = "2022-10-13T00:00:00"
cron_obj = QuartzCron(schedule_string=schedule_string, start_date=start_date, end_date=end_date)
print(cron_obj.next_trigger(isoformat=True))
print(cron_obj.next_trigger(isoformat=True))
>> 2020-01-01T00:00:00
>> 2020-02-01T00:00:00
Or call .next_triggers()
with the number of triggers needed.
from cstriggers.core.trigger import QuartzCron
schedule_string = "0 0 0 1 JAN-MAR ? 2010-2030"
start_date = "2019-10-13T00:00:00"
end_date = "2022-10-13T00:00:00"
cron_obj = QuartzCron(schedule_string=schedule_string, start_date=start_date, end_date=end_date)
print(cron_obj.next_triggers(number_of_triggers=10, isoformat=True))
>> [
'2020-01-01T00:00:00',
'2020-02-01T00:00:00',
'2020-03-01T00:00:00',
'2021-01-01T00:00:00',
'2021-02-01T00:00:00',
'2021-03-01T00:00:00',
'2022-01-01T00:00:00',
'2022-02-01T00:00:00',
'2022-03-01T00:00:00',
'2023-01-01T00:00:00'
]
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
Built Distribution
Hashes for cron-schedule-triggers-0.0.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4bd0d19facea2de7f6f011bd558a83f4959d71fd66645e32f722942219b9d196 |
|
MD5 | 7b57628b9b6d633266512a9cfa432dfa |
|
BLAKE2b-256 | 0d7d069fc89aca5eb2578cb07addad1fb6d427c8a9f50fa148038927ddc03080 |
Hashes for cron_schedule_triggers-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bcabd6b08265d16d481fac6fead89ed1aa563306d6b0cdba3367a241f9be4e3c |
|
MD5 | aad85a8dacbb0c8404532c3b8ebdcc10 |
|
BLAKE2b-256 | 6aa5146db788d357823774ebe9ed9f2668e2e76aa164bf84479c754f51552d65 |