diff --git a/EDMC.py b/EDMC.py index 2cc276c6..6819a219 100755 --- a/EDMC.py +++ b/EDMC.py @@ -56,10 +56,6 @@ try: elif not data.get('ship') or not data['ship'].get('modules') or not data['ship'].get('name','').strip(): sys.stderr.write('What are you flying?!\n') # Shouldn't happen sys.exit(EXIT_SERVER) - elif (args.m or args.o or args.s) and not data['commander'].get('docked'): - print data['lastSystem']['name'] - sys.stderr.write("You're not docked at a station!\n") - sys.exit(EXIT_NOT_DOCKED) # stuff we can do when not docked if args.c: @@ -67,11 +63,19 @@ try: if args.e: loadout.export(data, args.e) + if not data['commander'].get('docked'): + print data['lastSystem']['name'] + if (args.m or args.o or args.s): + sys.stderr.write("You're not docked at a station!\n") + sys.exit(EXIT_NOT_DOCKED) + else: + sys.exit(EXIT_SUCCESS) + # Finally - the data looks sane and we're docked at a station print '%s,%s' % (data['lastSystem']['name'], data['lastStarport']['name']) - (station_id, has_shipyard, has_outfitting) = EDDB.station(data['lastSystem']['name'], data['lastStarport']['name']) + (station_id, has_market, has_outfitting, has_shipyard) = EDDB.station(data['lastSystem']['name'], data['lastStarport']['name']) - if not data['lastStarport'].get('commodities') and not has_outfitting and not has_shipyard: + if not (has_market or data['lastStarport'].get('commodities')) and not has_outfitting and not has_shipyard: sys.stderr.write("Station doesn't have anything!\n") sys.exit(EXIT_SUCCESS) @@ -80,6 +84,8 @@ try: # Fixup anomalies in the commodity data session.fixup(data['lastStarport']['commodities']) bpc.export(data, True, args.m) + elif has_market: + sys.stderr.write("Error: Can't get market data!\n") else: sys.stderr.write("Station doesn't have a market\n") @@ -94,7 +100,7 @@ try: if not data['lastStarport'].get('ships'): sleep(SERVER_RETRY) data = session.query() - if data['lastStarport'].get('ships'): + if data['lastStarport'].get('ships') and data['commander'].get('docked'): shipyard.export(data, args.s) else: sys.stderr.write("Couldn't retrieve shipyard info\n") diff --git a/EDMarketConnector.py b/EDMarketConnector.py index 62f56447..17a42387 100755 --- a/EDMarketConnector.py +++ b/EDMarketConnector.py @@ -289,13 +289,13 @@ class AppWindow: else: # Finally - the data looks sane and we're docked at a station - (station_id, has_shipyard, has_outfitting) = EDDB.station(self.system['text'], self.station['text']) + (station_id, has_market, has_outfitting, has_shipyard) = EDDB.station(self.system['text'], self.station['text']) - if (config.getint('output') & config.OUT_EDDN) and not data['lastStarport'].get('commodities') and not has_outfitting and not has_shipyard: + if (config.getint('output') & config.OUT_EDDN) and not (has_market or data['lastStarport'].get('commodities')) and not has_outfitting and not has_shipyard: if not self.status['text']: self.status['text'] = _("Station doesn't have anything!") - elif not (config.getint('output') & config.OUT_EDDN) and not data['lastStarport'].get('commodities'): + elif not (config.getint('output') & config.OUT_EDDN) and not (has_market or data['lastStarport'].get('commodities')): if not self.status['text']: self.status['text'] = _("Station doesn't have a market!") @@ -311,6 +311,10 @@ class AppWindow: if config.getint('output') & config.OUT_BPC: bpc.export(data, False) + elif has_market and (config.getint('output') & (config.OUT_CSV|config.OUT_TD|config.OUT_BPC|config.OUT_EDDN)): + # Overwrite any previous error message + self.status['text'] = _("Error: Can't get market data!") + if config.getint('output') & config.OUT_EDDN: old_status = self.status['text'] if not old_status: @@ -420,7 +424,7 @@ class AppWindow: def station_url(self, text): if text: - (station_id, has_shipyard, has_outfitting) = EDDB.station(self.system['text'], self.station['text']) + (station_id, has_market, has_outfitting, has_shipyard) = EDDB.station(self.system['text'], self.station['text']) if station_id: return 'http://eddb.io/station/%d' % station_id diff --git a/L10n/en.template b/L10n/en.template index a5ee43d1..0118283d 100644 --- a/L10n/en.template +++ b/L10n/en.template @@ -46,6 +46,9 @@ /* [edsm.py] */ "Error: Can't connect to EDSM" = "Error: Can't connect to EDSM"; +/* [EDMarketConnector.py] */ +"Error: Can't get market data!" = "Error: Can't get market data!"; + /* [EDMarketConnector.py] */ "Error: Connection to EDDN timed out" = "Error: Connection to EDDN timed out"; diff --git a/L10n/fr.strings b/L10n/fr.strings index d632c122..7dbea20b 100644 --- a/L10n/fr.strings +++ b/L10n/fr.strings @@ -198,3 +198,6 @@ /* Output settings prompt. [prefs.py] */ "Re-start Elite: Dangerous to use this feature" = "Redémarrer Elite: Dangerous pour utiliser cette fonctionnalité"; + +/* [EDMarketConnector.py] */ +"Error: Can't get market data!" = "Erreur: Impossible d'obtenir les données du marché!"; diff --git a/L10n/it.strings b/L10n/it.strings index a62deedf..1d2739d7 100644 --- a/L10n/it.strings +++ b/L10n/it.strings @@ -198,3 +198,6 @@ /* Output settings prompt. [prefs.py] */ "Re-start Elite: Dangerous to use this feature" = "Riavviare Elite:Dangerous per usare questa funzione"; + +/* [EDMarketConnector.py] */ +"Error: Can't get market data!" = "Errore: Non riesco a ottenere il market data!"; diff --git a/eddb.py b/eddb.py index 52131e02..6b626031 100755 --- a/eddb.py +++ b/eddb.py @@ -11,6 +11,10 @@ from sys import platform class EDDB: + HAS_MARKET = 1 + HAS_OUTFITTING = 2 + HAS_SHIPYARD = 4 + def __init__(self): self.system_ids = cPickle.load(open(join(self.respath(), 'systems.p'), 'rb')) self.station_ids = cPickle.load(open(join(self.respath(), 'stations.p'), 'rb')) @@ -19,9 +23,10 @@ class EDDB: def system(self, system_name): return self.system_ids.get(system_name, 0) # return 0 on failure (0 is not a valid id) - # (system_name, station_name) -> (station_id, has_shipyard, has_outfitting) + # (system_name, station_name) -> (station_id, has_market, has_outfitting, has_shipyard) def station(self, system_name, station_name): - return self.station_ids.get((self.system_ids.get(system_name), station_name), (0,False,False)) + (station_id, flags) = self.station_ids.get((self.system_ids.get(system_name), station_name), (0,0)) + return (station_id, bool(flags & EDDB.HAS_MARKET), bool(flags & EDDB.HAS_OUTFITTING), bool(flags & EDDB.HAS_SHIPYARD)) def respath(self): if getattr(sys, 'frozen', False): @@ -54,6 +59,6 @@ if __name__ == "__main__": cPickle.dump(system_ids, open('systems.p', 'wb'), protocol = cPickle.HIGHEST_PROTOCOL) # station_id by (system_id, station_name) - station_ids = dict([((x['system_id'], str(x['name'])), (x['id'], bool(x['has_shipyard']), bool(x['has_outfitting']))) for x in stations]) + station_ids = dict([((x['system_id'], str(x['name'])), (x['id'], (EDDB.HAS_MARKET if x['has_market'] else 0) | (EDDB.HAS_OUTFITTING if x['has_outfitting'] else 0) | (EDDB.HAS_SHIPYARD if x['has_shipyard'] else 0))) for x in stations]) cPickle.dump(station_ids, open('stations.p', 'wb'), protocol = cPickle.HIGHEST_PROTOCOL) diff --git a/stations.p b/stations.p index 51e5d70d..10a15541 100644 Binary files a/stations.p and b/stations.p differ