mirror of
https://github.com/EDCD/EDMarketConnector.git
synced 2025-04-12 15:27:14 +03:00
CAPI: Only perform queries for Live galaxy.
* This is *temporary* pending properly implementing utilising the Legacy CAPI host. * Check in the EDMarketConnector.EDApp.capi_request_data() function *and* also in some companion.session functions. But not absolutely all possible entry points because we'll be undoing it when we implement Legacy support. This *is* sufficient for the current core code entry points. If any plugin is invoking its own CAPI requests, well it shouldn't be.
This commit is contained in:
parent
4a8b5ed4b6
commit
4b31b67042
@ -944,7 +944,7 @@ class AppWindow(object):
|
||||
|
||||
return True
|
||||
|
||||
def capi_request_data(self, event=None) -> None:
|
||||
def capi_request_data(self, event=None) -> None: # noqa: CCR001
|
||||
"""
|
||||
Perform CAPI data retrieval and associated actions.
|
||||
|
||||
@ -969,6 +969,17 @@ class AppWindow(object):
|
||||
self.status['text'] = _('CAPI query aborted: Game mode unknown')
|
||||
return
|
||||
|
||||
if monitor.state['GameVersion'] is None:
|
||||
logger.trace_if('capi.worker', 'Aborting Query: GameVersion unknown')
|
||||
# LANG: CAPI queries aborted because GameVersion unknown
|
||||
self.status['text'] = _('CAPI query aborted: GameVersion unknown')
|
||||
return
|
||||
|
||||
if not monitor.is_live_galaxy():
|
||||
logger.warning("Dropping CAPI request because this is the Legacy galaxy, which is not yet supported")
|
||||
self.status['text'] = 'CAPI for Legacy not yet supported'
|
||||
return
|
||||
|
||||
if not monitor.system:
|
||||
logger.trace_if('capi.worker', 'Aborting Query: Current star system unknown')
|
||||
# LANG: CAPI queries aborted because current star system name unknown
|
||||
|
@ -214,6 +214,9 @@
|
||||
/* EDMarketConnector.py: CAPI queries aborted because game mode unknown; In files: EDMarketConnector.py:967; */
|
||||
"CAPI query aborted: Game mode unknown" = "CAPI query aborted: Game mode unknown";
|
||||
|
||||
/* EDMarketConnector.py: CAPI queries aborted because GameVersion unknown; In files: EDMarketConnector.py:974; */
|
||||
"CAPI query aborted: GameVersion unknown" = "CAPI query aborted: GameVersion unknown";
|
||||
|
||||
/* EDMarketConnector.py: CAPI queries aborted because current star system name unknown; In files: EDMarketConnector.py:973; */
|
||||
"CAPI query aborted: Current system unknown" = "CAPI query aborted: Current system unknown";
|
||||
|
||||
|
22
companion.py
22
companion.py
@ -55,6 +55,7 @@ auth_timeout = 30 # timeout for initial auth
|
||||
FRONTIER_AUTH_SERVER = 'https://auth.frontierstore.net'
|
||||
|
||||
SERVER_LIVE = 'https://companion.orerve.net'
|
||||
SERVER_LEGACY = 'https://legacy-companion.orerve.net'
|
||||
SERVER_BETA = 'https://pts-companion.orerve.net'
|
||||
|
||||
commodity_map: Dict = {}
|
||||
@ -679,7 +680,6 @@ class Session(object):
|
||||
self.close()
|
||||
self.credentials = credentials
|
||||
|
||||
self.server = self.credentials['beta'] and SERVER_BETA or SERVER_LIVE
|
||||
self.state = Session.STATE_INIT
|
||||
self.auth = Auth(self.credentials['cmdr'])
|
||||
|
||||
@ -743,7 +743,7 @@ class Session(object):
|
||||
"""Worker thread that performs actual CAPI queries."""
|
||||
logger.debug('CAPI worker thread starting')
|
||||
|
||||
def capi_single_query( # noqa: CCR001
|
||||
def capi_single_query(
|
||||
capi_endpoint: str, timeout: int = capi_default_requests_timeout
|
||||
) -> CAPIData:
|
||||
"""
|
||||
@ -754,6 +754,10 @@ class Session(object):
|
||||
:return: The resulting CAPI data, of type CAPIData.
|
||||
"""
|
||||
capi_data: CAPIData
|
||||
if not monitor.is_live_galaxy():
|
||||
logger.warning("Dropping CAPI request because this is the Legacy galaxy")
|
||||
return capi_data
|
||||
|
||||
try:
|
||||
logger.trace_if('capi.worker', 'Sending HTTP request...')
|
||||
if conf_module.capi_pretend_down:
|
||||
@ -936,7 +940,7 @@ class Session(object):
|
||||
)
|
||||
|
||||
# If the query came from EDMC.(py|exe) there's no tk to send an
|
||||
# event too, so assume it will be polling there response queue.
|
||||
# event too, so assume it will be polling the response queue.
|
||||
if query.tk_response_event is not None:
|
||||
logger.trace_if('capi.worker', 'Sending <<CAPIResponse>>')
|
||||
self.tk_master.event_generate('<<CAPIResponse>>')
|
||||
@ -964,6 +968,18 @@ class Session(object):
|
||||
:param play_sound: Whether the app should play a sound on error.
|
||||
:param auto_update: Whether this request was triggered automatically.
|
||||
"""
|
||||
if self.credentials is not None and self.credentials['beta']:
|
||||
self.server = SERVER_BETA
|
||||
|
||||
elif monitor.is_live_galaxy():
|
||||
self.server = SERVER_LIVE
|
||||
|
||||
else:
|
||||
logger.warning("Dropping CAPI request because this is the Legacy galaxy, which is not yet supported")
|
||||
# self.server = SERVER_LEGACY
|
||||
self.server = None
|
||||
return
|
||||
|
||||
# Ask the thread worker to perform all three queries
|
||||
logger.trace_if('capi.worker', 'Enqueueing request')
|
||||
self.capi_request_queue.put(
|
||||
|
Loading…
x
Reference in New Issue
Block a user