mirror of
https://github.com/EDCD/EDMarketConnector.git
synced 2025-04-15 16:50:34 +03:00
Add extra logging for Frontier Auth, especially via edmc://
This commit is contained in:
parent
1cd0392527
commit
4f524a0a35
@ -918,6 +918,7 @@ class AppWindow(object):
|
|||||||
|
|
||||||
# cAPI auth
|
# cAPI auth
|
||||||
def auth(self, event=None):
|
def auth(self, event=None):
|
||||||
|
logger.debug('Received "<<CompanionAuthEvent>>')
|
||||||
try:
|
try:
|
||||||
companion.session.auth_callback()
|
companion.session.auth_callback()
|
||||||
# Successfully authenticated with the Frontier website
|
# Successfully authenticated with the Frontier website
|
||||||
@ -925,14 +926,18 @@ class AppWindow(object):
|
|||||||
if platform == 'darwin':
|
if platform == 'darwin':
|
||||||
self.view_menu.entryconfigure(0, state=tk.NORMAL) # Status
|
self.view_menu.entryconfigure(0, state=tk.NORMAL) # Status
|
||||||
self.file_menu.entryconfigure(0, state=tk.NORMAL) # Save Raw Data
|
self.file_menu.entryconfigure(0, state=tk.NORMAL) # Save Raw Data
|
||||||
|
|
||||||
else:
|
else:
|
||||||
self.file_menu.entryconfigure(0, state=tk.NORMAL) # Status
|
self.file_menu.entryconfigure(0, state=tk.NORMAL) # Status
|
||||||
self.file_menu.entryconfigure(1, state=tk.NORMAL) # Save Raw Data
|
self.file_menu.entryconfigure(1, state=tk.NORMAL) # Save Raw Data
|
||||||
|
|
||||||
except companion.ServerError as e:
|
except companion.ServerError as e:
|
||||||
self.status['text'] = str(e)
|
self.status['text'] = str(e)
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.debug('Frontier CAPI Auth:', exc_info=e)
|
logger.debug('Frontier CAPI Auth:', exc_info=e)
|
||||||
self.status['text'] = str(e)
|
self.status['text'] = str(e)
|
||||||
|
|
||||||
self.cooldown()
|
self.cooldown()
|
||||||
|
|
||||||
# Handle Status event
|
# Handle Status event
|
||||||
|
@ -263,6 +263,7 @@ class Auth(object):
|
|||||||
|
|
||||||
except (ValueError, requests.RequestException, ):
|
except (ValueError, requests.RequestException, ):
|
||||||
logger.exception(f"Frontier CAPI Auth: Can't refresh token for \"{self.cmdr}\"")
|
logger.exception(f"Frontier CAPI Auth: Can't refresh token for \"{self.cmdr}\"")
|
||||||
|
self.dump(r)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
logger.error(f"Frontier CAPI Auth: No token for \"{self.cmdr}\"")
|
logger.error(f"Frontier CAPI Auth: No token for \"{self.cmdr}\"")
|
||||||
@ -360,7 +361,11 @@ class Auth(object):
|
|||||||
# noinspection PyMethodMayBeStatic
|
# noinspection PyMethodMayBeStatic
|
||||||
def dump(self, r: requests.Response) -> None:
|
def dump(self, r: requests.Response) -> None:
|
||||||
"""Dump details of HTTP failure from oAuth attempt."""
|
"""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
|
# noinspection PyMethodMayBeStatic
|
||||||
def base64_url_encode(self, text: bytes) -> str:
|
def base64_url_encode(self, text: bytes) -> str:
|
||||||
|
@ -37,6 +37,7 @@ class GenericProtocolHandler(object):
|
|||||||
self.lastpayload = url
|
self.lastpayload = url
|
||||||
|
|
||||||
if not config.shutting_down:
|
if not config.shutting_down:
|
||||||
|
logger.debug('event_generate("<<CompanionAuthEvent>>"')
|
||||||
self.master.event_generate('<<CompanionAuthEvent>>', when="tail")
|
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)
|
None)
|
||||||
msg = MSG()
|
msg = MSG()
|
||||||
while GetMessage(byref(msg), None, 0, 0) != 0:
|
while GetMessage(byref(msg), None, 0, 0) != 0:
|
||||||
|
logger.trace(f'DDE message of type: {msg.message}')
|
||||||
if msg.message == WM_DDE_EXECUTE:
|
if msg.message == WM_DDE_EXECUTE:
|
||||||
args = wstring_at(GlobalLock(msg.lParam)).strip()
|
args = wstring_at(GlobalLock(msg.lParam)).strip()
|
||||||
GlobalUnlock(msg.lParam)
|
GlobalUnlock(msg.lParam)
|
||||||
if args.lower().startswith('open("') and args.endswith('")'):
|
if args.lower().startswith('open("') and args.endswith('")'):
|
||||||
|
logger.trace(f'args are: {args}')
|
||||||
url = urllib.parse.unquote(args[6:-2]).strip()
|
url = urllib.parse.unquote(args[6:-2]).strip()
|
||||||
|
logger.trace(f'Parsed url: {url}')
|
||||||
if url.startswith(self.redirect):
|
if url.startswith(self.redirect):
|
||||||
|
logger.debug(f'Message starts with {self.redirect}')
|
||||||
self.event(url)
|
self.event(url)
|
||||||
SetForegroundWindow(GetParent(self.master.winfo_id())) # raise app window
|
SetForegroundWindow(GetParent(self.master.winfo_id())) # raise app window
|
||||||
PostMessage(msg.wParam, WM_DDE_ACK, hwnd, PackDDElParam(WM_DDE_ACK, 0x80, msg.lParam))
|
PostMessage(msg.wParam, WM_DDE_ACK, hwnd, PackDDElParam(WM_DDE_ACK, 0x80, msg.lParam))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user