From b630d7aa98c58bfa5d94f3bcb57e1dc63f6c92a4 Mon Sep 17 00:00:00 2001 From: suti7yk5032 Date: Thu, 25 Jul 2024 19:57:38 +0900 Subject: [PATCH] =?UTF-8?q?=E3=82=AB=E3=83=AC=E3=83=B3=E3=83=88=E3=83=87?= =?UTF-8?q?=E3=82=A3=E3=83=AC=E3=82=AF=E3=83=88=E3=83=AA=E3=81=AE=E5=87=A6?= =?UTF-8?q?=E7=90=86=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dislocker_client.py | 69 ++++++++++++++++++++++++--------------------- 1 file changed, 37 insertions(+), 32 deletions(-) diff --git a/dislocker_client.py b/dislocker_client.py index 5c0ec5b..a0230b6 100644 --- a/dislocker_client.py +++ b/dislocker_client.py @@ -14,38 +14,41 @@ import threading import signal import sys +app_name = "Dislocker" +dislocker_dir = os.getcwd() + +os.chdir(dislocker_dir) + +config_dir_path = "./config/" +client_config_path = config_dir_path + "client.json" +if not os.path.isfile(client_config_path): + if not os.path.isdir(config_dir_path): + os.mkdir(config_dir_path) + + client_config = { + "initial": 1, + "auth_host_url": "http://localhost", + "pc_number": 1, + "master_password_hash": "", + "testing": 0 + } + +elif os.path.isfile(client_config_path): + with open(client_config_path, "r") as r: + client_config = json.load(r) + def init(**kwargs): - app_name = "Dislocker" + master_password = master_password_gen() + msgbox = tkinter.messagebox.showinfo(title=f"{app_name} | 初回起動を検出", message=f"初回起動のようです。\nマスターパスワードを記録しておいてください。\nこれ以降二度と表示されることはないでしょう。\n\n{master_password["password"]}\n\nまた、認証先サーバーの接続先を指定してください。ロックを解除できなくなります。") + client_config["master_password_hash"] = master_password["password_hash"] + client_config["initial"] = 0 if "pc_number" in kwargs: - pc_number = int(kwargs["pc_number"]) + client_config["pc_number"] = int(kwargs["pc_number"]) else: - pc_number = 1 - config_dir_path = "./config/" - client_config_path = config_dir_path + "client.json" - if not os.path.isfile(client_config_path): - if not os.path.isdir(config_dir_path): - os.mkdir(config_dir_path) + client_config["pc_number"] = 1 + with open(client_config_path, "w") as w: + json.dump(client_config, w, indent=4) - client_config = { - "initial": 1, - "auth_host_url": "http://localhost", - "pc_number": 1, - "master_password_hash": "", - "testing": 0 - } - - elif os.path.isfile(client_config_path): - with open(client_config_path, "r") as r: - client_config = json.load(r) - - if client_config["initial"] == 1: - master_password = master_password_gen() - msgbox = tkinter.messagebox.showinfo(title=f"{app_name} | 初回起動を検出", message=f"初回起動のようです。\nマスターパスワードを記録しておいてください。\nこれ以降二度と表示されることはないでしょう。\n\n{master_password["password"]}\n\nまた、認証先サーバーの接続先を指定してください。ロックを解除できなくなります。") - client_config["master_password_hash"] = master_password["password_hash"] - client_config["initial"] = 0 - client_config["pc_number"] = pc_number - with open(client_config_path, "w") as w: - json.dump(client_config, w, indent=4) class App(customtkinter.CTk): def __init__(self): @@ -334,7 +337,9 @@ if __name__ == '__main__': else: print("引数エラー。") else: - init() - app = App() - app.protocol("WM_DELETE_WINDOW", app.handler_close) - app.mainloop() + if client_config["initial"] == 1: + init() + else: + app = App() + app.protocol("WM_DELETE_WINDOW", app.handler_close) + app.mainloop()