From d63d9cdb78e723a5015e98c20b68c59879d83244 Mon Sep 17 00:00:00 2001 From: Namonay Date: Wed, 25 Feb 2026 13:32:06 +0000 Subject: [PATCH] swag --- client/bs_shutdown.py | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/client/bs_shutdown.py b/client/bs_shutdown.py index 95cb1f8..5d9983b 100644 --- a/client/bs_shutdown.py +++ b/client/bs_shutdown.py @@ -37,13 +37,31 @@ def get_data(): def to_seconds(t): return t.hour * 3600 + t.minute * 60 + t.second +def set_shutdown(time, now): + global LAST_VALUE + + if (time - now) < 0 or time == LAST_VALUE: + return + LAST_VALUE = time + print("[BS Shutdown] shutting down in " + str(time - now) + " seconds") + # subprocess.run(["shutdown", "/s", "/t", (time - now), " "]) + + +def remove_shutdown(): + print("[BS Shutdown] Removed shutdown") + # subprocess.run(["shutdown", "/s", "/t", (time - now), " "]) + def update(): global LAST_VALUE + data = get_data() + if data is not None and data["noshutdown"] == 1: if (LAST_VALUE != 0): - subprocess.run(["shutdown", "/a"]) + LAST_VALUE = 0 + remove_shutdown() return + if data is None: time = to_seconds(datetime.strptime(DEFAULT_SHUTDOWN, "%H:%M").time()) else: @@ -54,17 +72,13 @@ def update(): return if (time == LAST_VALUE): - print("Nothing changed") return - if (time != LAST_VALUE): - if (LAST_VALUE != 0): - subprocess.run(["shutdown", "/a"]) - print("new val detected") - LAST_VALUE = time - print("shutting down in " + str(time - now) + " seconds") - # subprocess.run(["shutdown", "/s", "/t", (time - now), " "]) - print(time - now) + if (LAST_VALUE != 0): + remove_shutdown() + print("[BS Shutdown] New value") + LAST_VALUE = time + set_shutdown(time, now) if __name__ == '__main__': while True: