CronEdit...geht weiter
This commit is contained in:
parent
b1b941c82a
commit
39556f7613
3 changed files with 179 additions and 0 deletions
70
app.py
70
app.py
|
|
@ -912,6 +912,70 @@ def delete_word(category, word):
|
|||
return redirect(
|
||||
f"/categories/edit/{category}"
|
||||
)
|
||||
|
||||
def parse_cron_jobs(cron_jobs):
|
||||
|
||||
schedules = {}
|
||||
|
||||
for name, cron in cron_jobs.items():
|
||||
|
||||
schedules[name] = {
|
||||
"cron": cron,
|
||||
"minute": "",
|
||||
"hour": "",
|
||||
"interval": "",
|
||||
"days": []
|
||||
}
|
||||
|
||||
if (
|
||||
not cron
|
||||
or "Linux" in cron
|
||||
):
|
||||
continue
|
||||
|
||||
try:
|
||||
|
||||
minute, hour, day, month, weekday = (
|
||||
cron.split()
|
||||
)
|
||||
|
||||
schedules[name]["minute"] = minute
|
||||
|
||||
if hour.startswith("*/"):
|
||||
|
||||
schedules[name]["interval"] = (
|
||||
hour.replace(
|
||||
"*/",
|
||||
""
|
||||
)
|
||||
)
|
||||
|
||||
else:
|
||||
|
||||
schedules[name]["hour"] = hour
|
||||
|
||||
if "-" in weekday:
|
||||
|
||||
start, end = weekday.split("-")
|
||||
|
||||
schedules[name]["days"] = list(
|
||||
range(
|
||||
int(start),
|
||||
int(end) + 1
|
||||
)
|
||||
)
|
||||
|
||||
else:
|
||||
|
||||
schedules[name]["days"] = [
|
||||
int(weekday)
|
||||
]
|
||||
|
||||
except Exception:
|
||||
|
||||
pass
|
||||
|
||||
return schedules
|
||||
@app.route("/maintenance")
|
||||
def maintenance():
|
||||
|
||||
|
|
@ -922,11 +986,17 @@ def maintenance():
|
|||
""
|
||||
)
|
||||
cron_jobs = get_cron_jobs()
|
||||
|
||||
schedules = parse_cron_jobs(
|
||||
cron_jobs
|
||||
)
|
||||
print(schedules)
|
||||
return render_template(
|
||||
"maintenance.html",
|
||||
year=year,
|
||||
week=week,
|
||||
cron_jobs=cron_jobs,
|
||||
schedules=schedules,
|
||||
message=message
|
||||
)
|
||||
@app.route("/log")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue