シャットダウン時の使用停止処理を追加
This commit is contained in:
parent
18de0e7b85
commit
ab7147ffde
1 changed files with 30 additions and 0 deletions
|
@ -11,6 +11,8 @@ import string
|
|||
import random
|
||||
import tkinter
|
||||
import threading
|
||||
import signal
|
||||
import sys
|
||||
|
||||
class App(customtkinter.CTk):
|
||||
def __init__(self):
|
||||
|
@ -144,6 +146,7 @@ class Lock(customtkinter.CTkToplevel):
|
|||
|
||||
def auth_start(self):
|
||||
auth_thread = threading.Thread(target=self.auth)
|
||||
auth_thread.daemon = True
|
||||
auth_thread.start()
|
||||
|
||||
def auth(self):
|
||||
|
@ -223,7 +226,34 @@ class Help(customtkinter.CTkToplevel):
|
|||
def handler_close(self):
|
||||
self.destroy()
|
||||
|
||||
class Monitor():
|
||||
def __init__(self) -> None:
|
||||
pass
|
||||
|
||||
def start(self):
|
||||
monitor_thread = threading.Thread(target=self.run)
|
||||
monitor_thread.start()
|
||||
|
||||
def signal_handler(self, signum, frame):
|
||||
print("シャットダウンを検出。")
|
||||
stop_url = client_config["auth_host_url"] + "/stop"
|
||||
stop_json = {
|
||||
"pc_number": int(client_config["pc_number"])
|
||||
}
|
||||
try:
|
||||
responce = requests.post(stop_url, json=stop_json)
|
||||
if responce.status_code == 200:
|
||||
print("停止処理は成功しました。")
|
||||
self.exit()
|
||||
else:
|
||||
print("内部エラーにより停止処理に失敗しました。")
|
||||
except:
|
||||
print("ネットワークエラーにより停止処理に失敗しました。")
|
||||
finally:
|
||||
sys.exit()
|
||||
|
||||
def run(self):
|
||||
signal.signal(signal.SIGTERM, self.signal_handler)
|
||||
|
||||
|
||||
def master_password_gen():
|
||||
|
|
Loading…
Reference in a new issue