mirror of
https://github.com/EDCD/EDMarketConnector.git
synced 2025-04-14 00:07:14 +03:00
New specific error message for issue #6.
This commit is contained in:
parent
37651aa6e4
commit
393ade32af
20
EDMC.py
20
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")
|
||||
|
@ -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
|
||||
|
||||
|
@ -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";
|
||||
|
||||
|
@ -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é!";
|
||||
|
@ -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!";
|
||||
|
11
eddb.py
11
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)
|
||||
|
||||
|
BIN
stations.p
BIN
stations.p
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user