set up initial classes

This commit is contained in:
2024-02-25 11:18:37 +01:00
parent a9df4bb965
commit 6ef8fee79a
10 changed files with 68 additions and 38 deletions

View File

View File

@@ -5,43 +5,26 @@
{
"jobName": "Print schedule",
"jobType": "cyclic",
"jobFunction": "printScheduler",
"jobFunction": "output_schedule",
"dtTimeDelta": {
"minutes": 15
}
},
{
"jobName": "Example to show all possible scheduling options...",
"jobType": "once",
"jobFunction": "foo",
"dtTime": {
"_comment": "for minutely,hourly,daily,weekly & once jobs....",
"second": 0,
"minute": 0,
"hour": 0,
"dayOfWeek": [
"Monday",
"Tuesday",
"Wednesday",
"Thursday",
"Friday",
"Saturday",
"Sunday"
]
},
"jobName": "Output Alerts",
"jobType": "cyclic",
"jobFunction": "output_alerts",
"dtTimeDelta": {
"_comment": "for cyclic & once jobs, in x minutes....",
"minutes": 0
},
"dtDateTime": {
"_comment": "for once jobs, at point in time....",
"year": 2022,
"month": 1,
"day": 1,
"hour": 0,
"minute": 0
"seconds": 5
}
},
{
"jobName": "Update Alerts",
"jobType": "cyclic",
"jobFunction": "update_alerts",
"dtTimeDelta": {
"minutes": 1
}
}
]
}

View File

View File

@@ -0,0 +1 @@
alerts = []

View File

@@ -0,0 +1,18 @@
from globals import alerts
class outputAlerts:
alert_index = 0
alerts = []
def __init__(self) -> None:
self.alert_index = 0
self._get_alerts()
def print_next(self):
pass
def _get_alerts(self):
self.alerts = alerts.copy()

View File

@@ -0,0 +1,14 @@
from globals import alerts
class updateAlerts:
alerts = []
def __init__(self) -> None:
self._get_alerts()
def update(self):
pass
def _get_alerts(self):
self.alerts = alerts.copy()

View File

@@ -5,11 +5,23 @@ import json
import os.path
import time
def foo():
# print("\nJust chilling...\n")
return
from output_alerts import outputAlerts
from update_alerts import updateAlerts
def printScheduler():
printer = outputAlerts()
updater = updateAlerts()
def output_alerts():
print("Output-Alerts...")
printer.print_next()
pass
def update_alerts():
print("Update-Alerts...")
updater.update()
pass
def output_schedule():
date = dt.datetime.now()
print(str(date)+": The currently available jobs are:\n")
print(schedule)
@@ -26,15 +38,18 @@ def addParameter(name, object, dict):
def addDtTimeDeltaJob(job, schedule: Scheduler, function, once):
dtTimeDelta = job['dtTimeDelta']
if 'minutes' in dtTimeDelta:
if 'minutes' or 'seconds' in dtTimeDelta:
parameters = {}
addParameter('minutes', dtTimeDelta, parameters)
if 'minutes' in dtTimeDelta:
addParameter('minutes', dtTimeDelta, parameters)
if 'seconds' in dtTimeDelta:
addParameter('seconds', dtTimeDelta, parameters)
if once:
schedule.once(dt.timedelta(**parameters), function)
else:
schedule.cyclic(dt.timedelta(**parameters), function)
else:
print("ERROR: missing minutes in job: ", job['jobName'])
print("ERROR: missing time delta in job: ", job['jobName'])
return
def scheduleDayOfWeek(day, daylist, schedule, function, parameters, once):
@@ -168,7 +183,6 @@ def addJobs(schedule: Scheduler):
# schedule = Scheduler(n_threads=0)
schedule = Scheduler()
addJobs(schedule)
printScheduler()
while True:
start_time = time.perf_counter()