mirror of
https://github.com/EDCD/EDMarketConnector.git
synced 2025-06-09 20:02:11 +03:00
CAPI: Move CAPI response processing into AppWindow.capi_handle_response()
This commit is contained in:
parent
e79d219657
commit
2fc1568bf7
@ -926,11 +926,14 @@ class AppWindow(object):
|
|||||||
self.button['state'] = self.theme_button['state'] = tk.DISABLED
|
self.button['state'] = self.theme_button['state'] = tk.DISABLED
|
||||||
self.w.update_idletasks()
|
self.w.update_idletasks()
|
||||||
|
|
||||||
try:
|
|
||||||
querytime = int(time())
|
querytime = int(time())
|
||||||
data = companion.session.station()
|
data = companion.session.station()
|
||||||
config.set('querytime', querytime)
|
config.set('querytime', querytime)
|
||||||
|
|
||||||
|
|
||||||
|
def capi_handle_response(self, event=None):
|
||||||
|
"""Handle the resulting data from a CAPI query."""
|
||||||
|
data = ...
|
||||||
# Validation
|
# Validation
|
||||||
if 'commander' not in data:
|
if 'commander' not in data:
|
||||||
# This can happen with EGS Auth if no commander created yet
|
# This can happen with EGS Auth if no commander created yet
|
||||||
@ -1051,33 +1054,33 @@ class AppWindow(object):
|
|||||||
|
|
||||||
self.holdofftime = querytime + companion.holdoff
|
self.holdofftime = querytime + companion.holdoff
|
||||||
|
|
||||||
# Companion API problem
|
# # Companion API problem
|
||||||
except companion.ServerLagging as e:
|
# except companion.ServerLagging as e:
|
||||||
err = str(e)
|
# err = str(e)
|
||||||
if retrying:
|
# if retrying:
|
||||||
self.status['text'] = err
|
# self.status['text'] = err
|
||||||
play_bad = True
|
# play_bad = True
|
||||||
|
#
|
||||||
else:
|
# else:
|
||||||
# Retry once if Companion server is unresponsive
|
# # Retry once if Companion server is unresponsive
|
||||||
self.w.after(int(SERVER_RETRY * 1000), lambda: self.capi_request_data(event, True))
|
# self.w.after(int(SERVER_RETRY * 1000), lambda: self.capi_request_data(event, True))
|
||||||
return # early exit to avoid starting cooldown count
|
# return # early exit to avoid starting cooldown count
|
||||||
|
#
|
||||||
except companion.CmdrError as e: # Companion API return doesn't match Journal
|
# except companion.CmdrError as e: # Companion API return doesn't match Journal
|
||||||
err = self.status['text'] = str(e)
|
# err = self.status['text'] = str(e)
|
||||||
play_bad = True
|
# play_bad = True
|
||||||
companion.session.invalidate()
|
# companion.session.invalidate()
|
||||||
self.login()
|
# self.login()
|
||||||
|
#
|
||||||
except companion.ServerConnectionError as e:
|
# except companion.ServerConnectionError as e:
|
||||||
logger.warning(f'Exception while contacting server: {e}')
|
# logger.warning(f'Exception while contacting server: {e}')
|
||||||
err = self.status['text'] = str(e)
|
# err = self.status['text'] = str(e)
|
||||||
play_bad = True
|
# play_bad = True
|
||||||
|
#
|
||||||
except Exception as e: # Including CredentialsError, ServerError
|
# except Exception as e: # Including CredentialsError, ServerError
|
||||||
logger.debug('"other" exception', exc_info=e)
|
# logger.debug('"other" exception', exc_info=e)
|
||||||
err = self.status['text'] = str(e)
|
# err = self.status['text'] = str(e)
|
||||||
play_bad = True
|
# play_bad = True
|
||||||
|
|
||||||
if not err: # not self.status['text']: # no errors
|
if not err: # not self.status['text']: # no errors
|
||||||
# LANG: Time when we last obtained Frontier CAPI data
|
# LANG: Time when we last obtained Frontier CAPI data
|
||||||
@ -1090,10 +1093,6 @@ class AppWindow(object):
|
|||||||
self.suit_show_if_set()
|
self.suit_show_if_set()
|
||||||
self.cooldown()
|
self.cooldown()
|
||||||
|
|
||||||
def capi_handle_response(self, event=None):
|
|
||||||
"""Handle the resulting data from a CAPI query."""
|
|
||||||
...
|
|
||||||
|
|
||||||
def journal_event(self, event): # noqa: C901, CCR001 # Currently not easily broken up.
|
def journal_event(self, event): # noqa: C901, CCR001 # Currently not easily broken up.
|
||||||
"""
|
"""
|
||||||
Handle a Journal event passed through event queue from monitor.py.
|
Handle a Journal event passed through event queue from monitor.py.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user