a
This commit is contained in:
@@ -8,6 +8,12 @@ DEFAULT_SHUTDOWN = "21:00"
|
|||||||
|
|
||||||
LAST_VALUE = 0
|
LAST_VALUE = 0
|
||||||
|
|
||||||
|
machine_name = socket.gethostname()
|
||||||
|
url = "http://192.168.50.27:5000/lookup"
|
||||||
|
payload = {
|
||||||
|
"name": machine_name,
|
||||||
|
}
|
||||||
|
|
||||||
def get_data():
|
def get_data():
|
||||||
data = json.dumps(payload).encode("utf-8")
|
data = json.dumps(payload).encode("utf-8")
|
||||||
|
|
||||||
@@ -30,12 +36,7 @@ def get_data():
|
|||||||
def to_seconds(t):
|
def to_seconds(t):
|
||||||
return t.hour * 3600 + t.minute * 60 + t.second
|
return t.hour * 3600 + t.minute * 60 + t.second
|
||||||
|
|
||||||
machine_name = socket.gethostname()
|
def update():
|
||||||
url = "http://192.168.50.27:5000/lookup"
|
|
||||||
payload = {
|
|
||||||
"name": machine_name,
|
|
||||||
}
|
|
||||||
|
|
||||||
data = get_data()
|
data = get_data()
|
||||||
if data["noshutdown"] == 1:
|
if data["noshutdown"] == 1:
|
||||||
exit
|
exit
|
||||||
@@ -46,8 +47,14 @@ else:
|
|||||||
now = to_seconds(datetime.now().time())
|
now = to_seconds(datetime.now().time())
|
||||||
if (time - now) < 0:
|
if (time - now) < 0:
|
||||||
exit
|
exit
|
||||||
if (time != LAST_VALUE):
|
if (time != LAST_VALUE and LAST_VALUE != 0):
|
||||||
LAST_VALUE = time
|
LAST_VALUE = time
|
||||||
subprocess.run(["shutdown", "/a"])
|
subprocess.run(["shutdown", "/a"])
|
||||||
|
print("new val detected")
|
||||||
|
print("shutting down in " + (time - now) + " seconds")
|
||||||
# subprocess.run(["shutdown", "/s", "/t", (time - now), " "])
|
# subprocess.run(["shutdown", "/s", "/t", (time - now), " "])
|
||||||
print(time - now)
|
print(time - now)
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
update()
|
||||||
|
time.sleep(30)
|
||||||
Reference in New Issue
Block a user