srv/poe_manager/app.py aktualisiert
This commit is contained in:
@@ -122,12 +122,23 @@ def settings():
|
|||||||
|
|
||||||
if request.method == "POST":
|
if request.method == "POST":
|
||||||
new_interval = int(request.form["interval"])
|
new_interval = int(request.form["interval"])
|
||||||
|
|
||||||
|
# Minuten und Sekunden berechnen
|
||||||
|
interval_minutes = new_interval
|
||||||
|
check_interval_seconds = new_interval * 60
|
||||||
|
|
||||||
conn = sqlite3.connect("sqlite.db")
|
conn = sqlite3.connect("sqlite.db")
|
||||||
c = conn.cursor()
|
c = conn.cursor()
|
||||||
# upsert
|
# interval (Minuten)
|
||||||
c.execute("INSERT INTO settings (key, value) VALUES (?, ?) "
|
c.execute("""
|
||||||
"ON CONFLICT(key) DO UPDATE SET value=excluded.value",
|
INSERT INTO settings (key, value) VALUES (?, ?)
|
||||||
("interval", new_interval))
|
ON CONFLICT(key) DO UPDATE SET value=excluded.value
|
||||||
|
""", ("interval", interval_minutes))
|
||||||
|
# check_interval (Sekunden)
|
||||||
|
c.execute("""
|
||||||
|
INSERT INTO settings (key, value) VALUES (?, ?)
|
||||||
|
ON CONFLICT(key) DO UPDATE SET value=excluded.value
|
||||||
|
""", ("check_interval", check_interval_seconds))
|
||||||
conn.commit()
|
conn.commit()
|
||||||
conn.close()
|
conn.close()
|
||||||
|
|
||||||
@@ -135,7 +146,7 @@ def settings():
|
|||||||
import subprocess
|
import subprocess
|
||||||
subprocess.run(["systemctl", "restart", "rpi-check.service"])
|
subprocess.run(["systemctl", "restart", "rpi-check.service"])
|
||||||
|
|
||||||
flash(f"Intervall auf {new_interval} Minuten gesetzt und Service neu gestartet!")
|
flash(f"Intervall auf {interval_minutes} Minuten gesetzt und Service neu gestartet!")
|
||||||
return redirect(url_for("settings"))
|
return redirect(url_for("settings"))
|
||||||
|
|
||||||
return render_template("settings.html", interval=interval)
|
return render_template("settings.html", interval=interval)
|
||||||
|
|||||||
Reference in New Issue
Block a user