From 5ddadac47c94d1139e8d4492a0e8fc8eec8a8146 Mon Sep 17 00:00:00 2001 From: Ivan Date: Wed, 28 Apr 2021 14:46:28 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=BE=D1=84=D0=B8=D0=BA=D1=81=D0=B8?= =?UTF-8?q?=D0=BB=20=D0=B0=D0=BF=D0=B8=20=D1=81=D0=BE=D1=85=D1=80=D0=B0?= =?UTF-8?q?=D0=BD=D0=B5=D0=BD=D0=B8=D1=8F=20=D1=82=D0=BE=D0=BA=D0=B5=D0=BD?= =?UTF-8?q?=D0=BE=D0=B2=20=D0=B8=20=D1=80=D0=B5=D0=B6=D0=B8=D0=BC=20=D0=BE?= =?UTF-8?q?=D1=82=D0=BB=D0=B0=D0=B4=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/todo_tk.py | 9 ++++++--- frontend/user.py | 8 ++++++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/frontend/todo_tk.py b/frontend/todo_tk.py index e97c352..0336afd 100644 --- a/frontend/todo_tk.py +++ b/frontend/todo_tk.py @@ -26,9 +26,12 @@ class Application(tk.Tk): def login(self): """Возвращает пользователя - его можно потом сериализовать""" # Пользователь сохранен! Авторизация не нужна! - user = User.load() - if user is not None: - return user + try: + user = User.load() + if user is not None: + return user + except Exception as e: + print("Failed to restore login:", e) # Не удалось - нужен логин self.frame = LoginFrame(master=self, url=DEFAULT_URL) while not self.frame.loggedIn: diff --git a/frontend/user.py b/frontend/user.py index e5e6baf..7c58714 100644 --- a/frontend/user.py +++ b/frontend/user.py @@ -161,6 +161,9 @@ class User(UserApi): """ Remove the login file from homedir """ + if "DEBUG" in os.environ: + print("Debug mode is on - no login storing") + return if not os.path.exists(USER_TOKEN_PATH): return try: @@ -172,6 +175,9 @@ class User(UserApi): """ Store user token in homedir """ + if "DEBUG" in os.environ: + print("Debug mode is on - no login storing") + return try: with open(USER_TOKEN_PATH, "w") as handler: json.dump(self.token.__dict__, handler) @@ -183,6 +189,8 @@ class User(UserApi): """ Restore user token from the file in homedir """ + if "DEBUG" in os.environ: + raise RuntimeError("Debug mode is on - no login storing") if os.path.exists(USER_TOKEN_PATH): try: with open(USER_TOKEN_PATH, "r") as handler: