1
0
mirror of https://github.com/EDCD/EDMarketConnector.git synced 2025-04-14 00:07:14 +03:00

Add extra logging for Frontier Auth, especially via edmc://

This commit is contained in:
Athanasius 2021-03-15 12:07:39 +00:00
parent 1cd0392527
commit 4f524a0a35
3 changed files with 16 additions and 1 deletions

View File

@ -918,6 +918,7 @@ class AppWindow(object):
# cAPI auth
def auth(self, event=None):
logger.debug('Received "<<CompanionAuthEvent>>')
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

View File

@ -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:

View File

@ -37,6 +37,7 @@ class GenericProtocolHandler(object):
self.lastpayload = url
if not config.shutting_down:
logger.debug('event_generate("<<CompanionAuthEvent>>"')
self.master.event_generate('<<CompanionAuthEvent>>', when="tail")
@ -190,12 +191,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))