set up initial classes
This commit is contained in:
0
alert-scheduler/__init__.py
Normal file
0
alert-scheduler/__init__.py
Normal 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
|
||||
}
|
||||
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
0
alert-scheduler/src/__init__.py
Normal file
0
alert-scheduler/src/__init__.py
Normal file
BIN
alert-scheduler/src/__pycache__/globals.cpython-310.pyc
Normal file
BIN
alert-scheduler/src/__pycache__/globals.cpython-310.pyc
Normal file
Binary file not shown.
BIN
alert-scheduler/src/__pycache__/output_alerts.cpython-310.pyc
Normal file
BIN
alert-scheduler/src/__pycache__/output_alerts.cpython-310.pyc
Normal file
Binary file not shown.
BIN
alert-scheduler/src/__pycache__/update_alerts.cpython-310.pyc
Normal file
BIN
alert-scheduler/src/__pycache__/update_alerts.cpython-310.pyc
Normal file
Binary file not shown.
1
alert-scheduler/src/globals.py
Normal file
1
alert-scheduler/src/globals.py
Normal file
@@ -0,0 +1 @@
|
||||
alerts = []
|
||||
18
alert-scheduler/src/output_alerts.py
Normal file
18
alert-scheduler/src/output_alerts.py
Normal 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()
|
||||
|
||||
14
alert-scheduler/src/update_alerts.py
Normal file
14
alert-scheduler/src/update_alerts.py
Normal 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()
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user