diff --git a/client/bs_shutdown.py b/client/bs_shutdown.py index 5e9882e..a9921c8 100644 --- a/client/bs_shutdown.py +++ b/client/bs_shutdown.py @@ -46,7 +46,7 @@ def set_shutdown(time, now): return LAST_VALUE = time print("[BS Shutdown] shutting down in " + str(time - now) + " seconds") - subprocess.run(["shutdown", "-r", "-t", str(time - now)]) + subprocess.run(["shutdown", "-r", "-f", "-t", str(time - now)]) def remove_shutdown(): diff --git a/server/src/data/app.py b/server/src/data/app.py index cec4045..d7f4aa0 100644 --- a/server/src/data/app.py +++ b/server/src/data/app.py @@ -1,16 +1,19 @@ from flask import Flask, render_template, request, redirect, url_for, jsonify import sqlite3 import re +from datetime import datetime +# -- INIT -- app = Flask(__name__) - pattern = re.compile(r"^(?:[01]\d|2[0-3]):[0-5]\d$") # Regex "XX:XX" +# -- GLOBAL VAR -- DB_PATH = "data.db" DEFAULT_TIME = "21:00" + +## -- INIT DB -- conn = sqlite3.connect(DB_PATH) cursor = conn.cursor() - cursor.execute(""" CREATE TABLE IF NOT EXISTS items ( id INTEGER PRIMARY KEY AUTOINCREMENT, @@ -30,11 +33,13 @@ if count == 0: cursor.execute("INSERT INTO val (default_time) VALUES (?)", ('21:00',)) conn.commit() conn.close() +# -- END -- def get_db_connection(): conn = sqlite3.connect(DB_PATH) conn.row_factory = sqlite3.Row return conn + # --- MAIN --- @app.route("/") def mainpage(): @@ -122,6 +127,8 @@ def lookup(): cursor.execute("SELECT default_time FROM val") default_time_row = cursor.fetchone() default_time = default_time_row[0] if default_time_row else DEFAULT_TIME + if item: + corsor.execute("UPDATE items SET last_connection = ? WHERE name = ?", datetime.now(), item["name"]) conn.close() if item: diff --git a/server/src/data/templates/index.html b/server/src/data/templates/index.html index 665fe8f..0368984 100644 --- a/server/src/data/templates/index.html +++ b/server/src/data/templates/index.html @@ -66,57 +66,61 @@ -