From 33c88e5fbf00bb5d6f059e510e0f730335b7ffed Mon Sep 17 00:00:00 2001 From: Jonathan Harris Date: Tue, 15 Sep 2015 12:50:38 +0100 Subject: [PATCH] Better handle user dismissing the verifaction dialog. --- EDMarketConnector.py | 1 + companion.py | 2 ++ prefs.py | 6 ++++++ 3 files changed, 9 insertions(+) diff --git a/EDMarketConnector.py b/EDMarketConnector.py index 6783caf5..e1b8ca7b 100755 --- a/EDMarketConnector.py +++ b/EDMarketConnector.py @@ -226,6 +226,7 @@ class AppWindow: self.session.verify(code) except Exception as e: if __debug__: print_exc() + self.button['state'] = tk.NORMAL self.status['text'] = unicode(e) else: return self.getandsend() # try again diff --git a/companion.py b/companion.py index e18a5714..5c4c9394 100644 --- a/companion.py +++ b/companion.py @@ -166,6 +166,8 @@ class Session: return r.status_code def verify(self, code): + if not code: + raise VerificationRequired() r = self.session.post(URL_CONFIRM, data = {'code' : code}, timeout=timeout) r.raise_for_status() # verification doesn't actually return a yes/no, so log in again to determine state diff --git a/prefs.py b/prefs.py index 928c2f03..a15037d5 100644 --- a/prefs.py +++ b/prefs.py @@ -331,6 +331,8 @@ class AuthenticationDialog(tk.Toplevel): for child in frame.winfo_children(): child.grid_configure(padx=5, pady=5) + self.protocol("WM_DELETE_WINDOW", self._destroy) + # wait for window to appear on screen before calling grab_set self.wait_visibility() self.grab_set() @@ -344,3 +346,7 @@ class AuthenticationDialog(tk.Toplevel): code = self.code.get().strip() self.destroy() if self.callback: self.callback(code) + + def _destroy(self): + self.destroy() + if self.callback: self.callback(None)