|
4 | 4 | __author__ = 'Simon Robinson' |
5 | 5 | __copyright__ = 'Copyright (c) 2022 Simon Robinson' |
6 | 6 | __license__ = 'Apache 2.0' |
7 | | -__version__ = '2022-08-03' # ISO 8601 (YYYY-MM-DD) |
| 7 | +__version__ = '2022-08-17' # ISO 8601 (YYYY-MM-DD) |
8 | 8 |
|
9 | 9 | import argparse |
10 | 10 | import asyncore |
@@ -1753,15 +1753,18 @@ def authorise_account(self, _, item): |
1753 | 1753 | if not self.web_view_started: |
1754 | 1754 | # pywebview on macOS needs start() to be called only once, so we use a dummy window to keep it open |
1755 | 1755 | # Windows is the opposite - the macOS technique freezes the tray icon; Linux is fine either way |
| 1756 | + # (we also set pywebview debug mode to match our own mode because copy/paste via keyboard shortcuts |
| 1757 | + # can be unreliable with 'mshtml'; and, python virtual environments sometimes break keyboard entry |
| 1758 | + # entirely on macOS - debug mode works around this in both cases via the right-click context menu) |
1756 | 1759 | self.create_authorisation_window(request) |
1757 | 1760 | if sys.platform == 'darwin': |
1758 | | - webview.start(self.handle_authorisation_windows) |
| 1761 | + webview.start(self.handle_authorisation_windows, debug=Log.get_level() == logging.DEBUG) |
1759 | 1762 | self.web_view_started = True # note: not set for other platforms so we start() every time |
1760 | 1763 | else: |
1761 | 1764 | # on Windows, most pywebview engine options return None for get_current_url() on pages created |
1762 | 1765 | # using 'html=' even on redirection to an actual URL; 'mshtml', though archaic, does work |
1763 | 1766 | forced_gui = 'mshtml' if sys.platform == 'win32' and self.args.external_auth else None |
1764 | | - webview.start(gui=forced_gui) |
| 1767 | + webview.start(gui=forced_gui, debug=Log.get_level() == logging.DEBUG) |
1765 | 1768 | else: |
1766 | 1769 | WEBVIEW_QUEUE.put(request) # future requests need to use the same thread |
1767 | 1770 | return |
@@ -1828,6 +1831,9 @@ def authorisation_window_loaded(self): |
1828 | 1831 | RESPONSE_QUEUE.put({'connection': request['connection'], 'response_url': url}) |
1829 | 1832 | self.authorisation_requests.remove(request) |
1830 | 1833 | completed_request = request |
| 1834 | + else: |
| 1835 | + Log.debug('Waiting for URL matching `redirect_uri`; following browser redirection to', |
| 1836 | + '%s/[...]' % urllib.parse.urlparse(url).hostname) |
1831 | 1837 |
|
1832 | 1838 | if completed_request is None: |
1833 | 1839 | continue # no requests processed for this window - nothing to do yet |
|
0 commit comments