mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2025-12-07 09:36:05 -08:00
make scheduler setup more robust against wrong scheduling
is the schedule input is incorrect, an error message is logged and the plugin will NOT run. Creating a dummy schedule would throw the system out of balance as there's the danger of schedules running out of sync.
This commit is contained in:
@@ -368,8 +368,19 @@ def importConfigs (pm, db, all_plugins):
|
||||
# mylog('verbose', [f"[Config] pref {plugin["unique_prefix"]} run_val {run_val} run_sch {run_sch} "])
|
||||
|
||||
if run_val == 'schedule':
|
||||
newSchedule = Cron(run_sch).schedule(start_date=datetime.datetime.now(conf.tz))
|
||||
conf.mySchedules.append(schedule_class(plugin["unique_prefix"], newSchedule, newSchedule.next(), False))
|
||||
newSchedule = None
|
||||
try:
|
||||
newSchedule = Cron(run_sch).schedule(start_date=datetime.datetime.now(conf.tz))
|
||||
if (newSchedule is not None):
|
||||
conf.mySchedules.append(schedule_class(plugin["unique_prefix"], newSchedule, newSchedule.next(), False))
|
||||
else:
|
||||
raise(ValueError("Invalid schedule"))
|
||||
except ValueError as e:
|
||||
mylog('none', [f"[Config] [ERROR] Invalid schedule '{run_sch}' for plugin '{plugin['unique_prefix']}'. Error: {e}."])
|
||||
except Exception as e:
|
||||
mylog('none', [f"[Config] [ERROR] Could not set schedule '{run_sch}' for plugin '{plugin['unique_prefix']}'. Error: {e}."])
|
||||
|
||||
|
||||
|
||||
# mylog('verbose', [f"[Config] conf.mySchedules {conf.mySchedules}"])
|
||||
|
||||
|
||||
Reference in New Issue
Block a user