diff --git a/EDMarketConnector.py b/EDMarketConnector.py index 764568ec..b33d9498 100755 --- a/EDMarketConnector.py +++ b/EDMarketConnector.py @@ -918,6 +918,7 @@ class AppWindow(object): # cAPI auth def auth(self, event=None): + logger.debug('Received "<>') try: companion.session.auth_callback() # Successfully authenticated with the Frontier website @@ -925,14 +926,18 @@ class AppWindow(object): if platform == 'darwin': self.view_menu.entryconfigure(0, state=tk.NORMAL) # Status self.file_menu.entryconfigure(0, state=tk.NORMAL) # Save Raw Data + else: self.file_menu.entryconfigure(0, state=tk.NORMAL) # Status self.file_menu.entryconfigure(1, state=tk.NORMAL) # Save Raw Data + except companion.ServerError as e: self.status['text'] = str(e) + except Exception as e: logger.debug('Frontier CAPI Auth:', exc_info=e) self.status['text'] = str(e) + self.cooldown() # Handle Status event diff --git a/companion.py b/companion.py index 850f3a7a..36fb62cb 100644 --- a/companion.py +++ b/companion.py @@ -263,6 +263,7 @@ class Auth(object): except (ValueError, requests.RequestException, ): logger.exception(f"Frontier CAPI Auth: Can't refresh token for \"{self.cmdr}\"") + self.dump(r) else: logger.error(f"Frontier CAPI Auth: No token for \"{self.cmdr}\"") @@ -360,7 +361,11 @@ class Auth(object): # noinspection PyMethodMayBeStatic def dump(self, r: requests.Response) -> None: """Dump details of HTTP failure from oAuth attempt.""" - logger.debug(f'Frontier CAPI Auth: {r.url} {r.status_code} {r.reason if r.reason else "None"} {r.text}') + if r: + logger.debug(f'Frontier CAPI Auth: {r.url} {r.status_code} {r.reason if r.reason else "None"} {r.text}') + + else: + logger.debug(f'Frontier CAPI Auth: failed with `r` False: {r!r}') # noinspection PyMethodMayBeStatic def base64_url_encode(self, text: bytes) -> str: @@ -432,8 +437,8 @@ class Session(object): # Callback from protocol handler def auth_callback(self) -> None: - """Handle callback from edmc:// handler.""" - logger.debug('Handling callback from edmc:// handler') + """Handle callback from edmc:// or localhost:/auth handler.""" + logger.debug('Handling auth callback') if self.state != Session.STATE_AUTH: # Shouldn't be getting a callback logger.debug('Got an auth callback while not doing auth') diff --git a/protocol.py b/protocol.py index 9dd9aba5..dcaa8b99 100644 --- a/protocol.py +++ b/protocol.py @@ -36,7 +36,9 @@ class GenericProtocolHandler(object): def event(self, url): self.lastpayload = url + logger.trace(f'Payload: {self.lastpayload}') if not config.shutting_down: + logger.debug('event_generate("<>"') self.master.event_generate('<>', when="tail") @@ -190,12 +192,16 @@ elif sys.platform == 'win32' and getattr(sys, 'frozen', False) and not is_wine a None) msg = MSG() while GetMessage(byref(msg), None, 0, 0) != 0: + logger.trace(f'DDE message of type: {msg.message}') if msg.message == WM_DDE_EXECUTE: args = wstring_at(GlobalLock(msg.lParam)).strip() GlobalUnlock(msg.lParam) if args.lower().startswith('open("') and args.endswith('")'): + logger.trace(f'args are: {args}') url = urllib.parse.unquote(args[6:-2]).strip() + logger.trace(f'Parsed url: {url}') if url.startswith(self.redirect): + logger.debug(f'Message starts with {self.redirect}') self.event(url) SetForegroundWindow(GetParent(self.master.winfo_id())) # raise app window PostMessage(msg.wParam, WM_DDE_ACK, hwnd, PackDDElParam(WM_DDE_ACK, 0x80, msg.lParam)) @@ -242,8 +248,10 @@ else: # Linux / Run from source class HTTPRequestHandler(BaseHTTPRequestHandler): def parse(self): + logger.trace(f'Got message on path: {self.path}') url = urllib.parse.unquote(self.path) if url.startswith('/auth'): + logger.debug('Request starts with /auth, sending to protocolhandler.event()') protocolhandler.event(url) self.send_response(200) return True