aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar jesopo2020-02-11 10:42:37 +0000
committerGravatar jesopo2020-02-11 10:42:37 +0000
commit04bc95c8a1ce6a4b33a8e1880cd2cbe61a7cf9ae (patch)
treeff7bb24c84d46c874bc7dda17b66b4ba58fbc204 /src
parent`usage` doesn't exist. return None instead (diff)
signature
add more cron timestamp fields, allow callbacks to runtime provide schedules
Diffstat (limited to 'src')
-rw-r--r--src/core_modules/cron.py16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/core_modules/cron.py b/src/core_modules/cron.py
index 8c619e59..e0c0ceb3 100644
--- a/src/core_modules/cron.py
+++ b/src/core_modules/cron.py
@@ -21,14 +21,20 @@ class Module(ModuleManager.BaseModule):
now = datetime.datetime.utcnow().replace(second=0, microsecond=0)
timer.redo()
- timestamp = [now.minute, now.hour]
+ timestamp = [now.minute, now.hour, now.day, now.month,
+ now.isoweekday()%7]
events = self.events.on("cron")
- event = events.make_event()
- for cron in events.get_hooks():
- schedule = cron.get_kwarg("schedule").split(" ")
+ def _check(schedule):
+ return self._schedule_match(timestamp, schedule.split(" "))
+ event = events.make_event(schedule=_check)
+
- if self._schedule_match(timestamp, schedule):
+ for cron in events.get_hooks():
+ schedule = cron.get_kwarg("schedule", None)
+ if schedule and not _check(schedule):
+ continue
+ else:
cron.call(event)
def _schedule_match(self, timestamp, schedule):