diff --git a/EDMarketConnector.py b/EDMarketConnector.py index 73f15e67..6f4b8c7c 100755 --- a/EDMarketConnector.py +++ b/EDMarketConnector.py @@ -662,17 +662,25 @@ class AppWindow(object): config.set('querytime', querytime) # Validation - if not data.get('commander', {}).get('name'): + if 'commander' not in data: + # This can happen with EGS Auth if no commander created yet + self.status['text'] = _('CAPI: No commander data returned') + + elif not data.get('commander', {}).get('name'): self.status['text'] = _("Who are you?!") # Shouldn't happen + elif (not data.get('lastSystem', {}).get('name') or (data['commander'].get('docked') and not data.get('lastStarport', {}).get('name'))): # Only care if docked self.status['text'] = _("Where are you?!") # Shouldn't happen + elif not data.get('ship', {}).get('name') or not data.get('ship', {}).get('modules'): self.status['text'] = _("What are you flying?!") # Shouldn't happen + elif monitor.cmdr and data['commander']['name'] != monitor.cmdr: # Companion API return doesn't match Journal raise companion.CmdrError() + elif ((auto_update and not data['commander'].get('docked')) or (data['lastSystem']['name'] != monitor.system) or ((data['commander']['docked'] diff --git a/L10n/en.template b/L10n/en.template index 23b4abcd..ef8f7399 100644 --- a/L10n/en.template +++ b/L10n/en.template @@ -46,6 +46,9 @@ /* Folder selection button on Windows. [prefs.py] */ "Browse..." = "Browse..."; +/* No 'commander' data in CAPI [EDMarketConnector.py] */ +"CAPI: No commander data returned" = "CAPI: No commander data returned"; + /* Federation rank. [stats.py] */ "Cadet" = "Cadet"; diff --git a/companion.py b/companion.py index b75d39ae..ba8faf1a 100644 --- a/companion.py +++ b/companion.py @@ -532,6 +532,10 @@ class Session(object): def station(self) -> CAPIData: """Perform CAPI /profile endpoint query for station data.""" data = self.query(URL_QUERY) + if 'commander' not in data: + logger.error('No commander in returned data') + return data + if not data['commander'].get('docked'): return data