add: timer & reboot
This commit is contained in:
@@ -46,7 +46,7 @@ def set_shutdown(time, now):
|
|||||||
return
|
return
|
||||||
LAST_VALUE = time
|
LAST_VALUE = time
|
||||||
print("[BS Shutdown] shutting down in " + str(time - now) + " seconds")
|
print("[BS Shutdown] shutting down in " + str(time - now) + " seconds")
|
||||||
subprocess.run(["shutdown", "-s", "-t", str(time - now)])
|
subprocess.run(["shutdown", "-r", "-t", str(time - now)])
|
||||||
|
|
||||||
|
|
||||||
def remove_shutdown():
|
def remove_shutdown():
|
||||||
@@ -84,4 +84,4 @@ def update():
|
|||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
while True:
|
while True:
|
||||||
update()
|
update()
|
||||||
time.sleep(30)
|
time.sleep(1800)
|
||||||
@@ -35,7 +35,7 @@ def get_db_connection():
|
|||||||
conn = sqlite3.connect(DB_PATH)
|
conn = sqlite3.connect(DB_PATH)
|
||||||
conn.row_factory = sqlite3.Row
|
conn.row_factory = sqlite3.Row
|
||||||
return conn
|
return conn
|
||||||
|
# --- MAIN ---
|
||||||
@app.route("/")
|
@app.route("/")
|
||||||
def mainpage():
|
def mainpage():
|
||||||
conn = get_db_connection()
|
conn = get_db_connection()
|
||||||
@@ -104,6 +104,8 @@ def delete():
|
|||||||
conn.close()
|
conn.close()
|
||||||
return redirect(url_for("mainpage"))
|
return redirect(url_for("mainpage"))
|
||||||
|
|
||||||
|
# --- END MAIN ---
|
||||||
|
# --- API ---
|
||||||
@app.route("/lookup", methods=["POST"])
|
@app.route("/lookup", methods=["POST"])
|
||||||
def lookup():
|
def lookup():
|
||||||
data = request.get_json()
|
data = request.get_json()
|
||||||
@@ -126,3 +128,4 @@ def lookup():
|
|||||||
return jsonify({"name": item["name"], "noshutdown": item["noshutdown"], "time": item["time"]}), 200
|
return jsonify({"name": item["name"], "noshutdown": item["noshutdown"], "time": item["time"]}), 200
|
||||||
else:
|
else:
|
||||||
return jsonify({"noshutdown": 0, "time": default_time}), 200
|
return jsonify({"noshutdown": 0, "time": default_time}), 200
|
||||||
|
# --- END API ---
|
||||||
Reference in New Issue
Block a user