カレントディレクトリの処理を追加

This commit is contained in:
suti7yk5032 2024-07-25 19:57:38 +09:00
parent a193d25877
commit b630d7aa98

View file

@ -14,15 +14,14 @@ import threading
import signal
import sys
def init(**kwargs):
app_name = "Dislocker"
if "pc_number" in kwargs:
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):
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)
@ -34,19 +33,23 @@ def init(**kwargs):
"testing": 0
}
elif os.path.isfile(client_config_path):
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:
def init(**kwargs):
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
if "pc_number" in kwargs:
client_config["pc_number"] = int(kwargs["pc_number"])
else:
client_config["pc_number"] = 1
with open(client_config_path, "w") as w:
json.dump(client_config, w, indent=4)
class App(customtkinter.CTk):
def __init__(self):
super().__init__()
@ -334,7 +337,9 @@ if __name__ == '__main__':
else:
print("引数エラー。")
else:
if client_config["initial"] == 1:
init()
else:
app = App()
app.protocol("WM_DELETE_WINDOW", app.handler_close)
app.mainloop()