mirror of
https://github.com/EDCD/EDMarketConnector.git
synced 2025-04-14 00:07:14 +03:00
Don't filter data based on station's entry in eddb
Assumes that FDev have fixed the issue behind #16 and similar for outfitting.
This commit is contained in:
parent
e658cccf96
commit
a5a4a8a415
24
EDMC.py
24
EDMC.py
@ -105,10 +105,7 @@ try:
|
||||
print '%s,%s' % (data['lastSystem']['name'], data['lastStarport']['name'])
|
||||
(station_id, has_market, has_outfitting, has_shipyard) = EDDB.station(data['lastSystem']['name'], data['lastStarport']['name'])
|
||||
|
||||
if station_id and not (has_market or has_outfitting or has_shipyard):
|
||||
sys.stderr.write("Station doesn't have anything!\n")
|
||||
sys.exit(EXIT_SUCCESS)
|
||||
elif not station_id and not (data['lastStarport'].get('commodities') or data['lastStarport'].get('modules')): # Ignore usually spurious shipyard at unknown stations
|
||||
if (args.m or args.o or args.s) and not (data['lastStarport'].get('commodities') or data['lastStarport'].get('modules')): # Ignore possibly missing shipyard info
|
||||
sys.stderr.write("Station doesn't have anything!\n")
|
||||
sys.exit(EXIT_SUCCESS)
|
||||
|
||||
@ -117,26 +114,23 @@ try:
|
||||
# Fixup anomalies in the commodity data
|
||||
session.fixup(data['lastStarport']['commodities'])
|
||||
commodity.export(data, COMMODITY_DEFAULT, 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")
|
||||
|
||||
if args.o:
|
||||
if has_outfitting or not station_id:
|
||||
if data['lastStarport'].get('modules'):
|
||||
outfitting.export(data, args.o)
|
||||
else:
|
||||
sys.stderr.write("Station doesn't supply outfitting\n")
|
||||
|
||||
if args.s:
|
||||
if has_shipyard:
|
||||
if not data['lastStarport'].get('ships'):
|
||||
sleep(SERVER_RETRY)
|
||||
data = session.query()
|
||||
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")
|
||||
if has_shipyard and not data['lastStarport'].get('ships'):
|
||||
sleep(SERVER_RETRY)
|
||||
data = session.query()
|
||||
if data['lastStarport'].get('ships'):
|
||||
shipyard.export(data, args.s)
|
||||
elif has_shipyard:
|
||||
sys.stderr.write("Couldn't retrieve shipyard info\n")
|
||||
else:
|
||||
sys.stderr.write("Station doesn't have a shipyard\n")
|
||||
|
||||
|
@ -408,23 +408,13 @@ class AppWindow:
|
||||
(station_id, has_market, has_outfitting, has_shipyard) = EDDB.station(self.system['text'], self.station['text'])
|
||||
|
||||
|
||||
# No EDDN output at known station?
|
||||
if (config.getint('output') & config.OUT_EDDN) and station_id and not (has_market or has_outfitting or has_shipyard):
|
||||
# No EDDN output?
|
||||
if (config.getint('output') & config.OUT_EDDN) and not (data['lastStarport'].get('commodities') or data['lastStarport'].get('modules')): # Ignore possibly missing shipyard info
|
||||
if not self.status['text']:
|
||||
self.status['text'] = _("Station doesn't have anything!")
|
||||
|
||||
# No EDDN output at unknown station?
|
||||
elif (config.getint('output') & config.OUT_EDDN) and not station_id and not (data['lastStarport'].get('commodities') or data['lastStarport'].get('modules')): # Ignore usually spurious shipyard at unknown stations
|
||||
if not self.status['text']:
|
||||
self.status['text'] = _("Station doesn't have anything!")
|
||||
|
||||
# No market output at known station?
|
||||
elif not (config.getint('output') & config.OUT_EDDN) and station_id and not has_market:
|
||||
if not self.status['text']:
|
||||
self.status['text'] = _("Station doesn't have a market!")
|
||||
|
||||
# No market output at unknown station?
|
||||
elif not (config.getint('output') & config.OUT_EDDN) and not station_id and not data['lastStarport'].get('commodities'):
|
||||
# No market output?
|
||||
elif not (config.getint('output') & config.OUT_EDDN) and not data['lastStarport'].get('commodities'):
|
||||
if not self.status['text']:
|
||||
self.status['text'] = _("Station doesn't have a market!")
|
||||
|
||||
@ -437,31 +427,18 @@ class AppWindow:
|
||||
if config.getint('output') & config.OUT_BPC:
|
||||
commodity.export(data, COMMODITY_BPC)
|
||||
|
||||
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:
|
||||
self.status['text'] = _('Sending data to EDDN...')
|
||||
self.w.update_idletasks()
|
||||
eddn.export_commodities(data)
|
||||
if has_outfitting or not station_id:
|
||||
# Only send if eddb says that the station provides outfitting, or unknown station
|
||||
eddn.export_outfitting(data)
|
||||
elif __debug__ and data['lastStarport'].get('modules'):
|
||||
print 'Spurious outfitting!'
|
||||
if has_shipyard:
|
||||
# Only send if eddb says that the station has a shipyard -
|
||||
# https://github.com/Marginal/EDMarketConnector/issues/16
|
||||
if data['lastStarport'].get('ships'):
|
||||
eddn.export_shipyard(data)
|
||||
else:
|
||||
# API is flakey about shipyard info - silently retry if missing (<1s is usually sufficient - 5s for margin).
|
||||
self.w.after(int(SERVER_RETRY * 1000), self.retry_for_shipyard)
|
||||
elif __debug__ and data['lastStarport'].get('ships'):
|
||||
print 'Spurious shipyard!'
|
||||
eddn.export_outfitting(data)
|
||||
if has_shipyard and not data['lastStarport'].get('ships'):
|
||||
# API is flakey about shipyard info - silently retry if missing (<1s is usually sufficient - 5s for margin).
|
||||
self.w.after(int(SERVER_RETRY * 1000), self.retry_for_shipyard)
|
||||
else:
|
||||
eddn.export_shipyard(data)
|
||||
if not old_status:
|
||||
self.status['text'] = ''
|
||||
|
||||
|
41
eddn.py
41
eddn.py
@ -72,27 +72,28 @@ def export_commodities(data):
|
||||
})
|
||||
|
||||
def export_outfitting(data):
|
||||
# *Do* send empty modules list - implies station has no outfitting
|
||||
schemakeys = ['category', 'name', 'mount', 'guidance', 'ship', 'class', 'rating']
|
||||
modules = []
|
||||
for v in data['lastStarport'].get('modules', {}).itervalues():
|
||||
try:
|
||||
module = outfitting.lookup(v, ship_map)
|
||||
if module:
|
||||
modules.append({ k: module[k] for k in schemakeys if k in module }) # just the relevant keys
|
||||
except AssertionError as e:
|
||||
if __debug__: print 'Outfitting: %s' % e # Silently skip unrecognized modules
|
||||
except:
|
||||
if __debug__: raise
|
||||
# Don't send empty modules list
|
||||
if data['lastStarport'].get('modules'):
|
||||
schemakeys = ['category', 'name', 'mount', 'guidance', 'ship', 'class', 'rating']
|
||||
modules = []
|
||||
for v in data['lastStarport'].get('modules', {}).itervalues():
|
||||
try:
|
||||
module = outfitting.lookup(v, ship_map)
|
||||
if module:
|
||||
modules.append({ k: module[k] for k in schemakeys if k in module }) # just the relevant keys
|
||||
except AssertionError as e:
|
||||
if __debug__: print 'Outfitting: %s' % e # Silently skip unrecognized modules
|
||||
except:
|
||||
if __debug__: raise
|
||||
|
||||
send(data['commander']['name'], {
|
||||
'$schemaRef' : 'http://schemas.elite-markets.net/eddn/outfitting/1',
|
||||
'message' : {
|
||||
'systemName' : data['lastSystem']['name'].strip(),
|
||||
'stationName' : data['lastStarport']['name'].strip(),
|
||||
'modules' : modules,
|
||||
}
|
||||
})
|
||||
send(data['commander']['name'], {
|
||||
'$schemaRef' : 'http://schemas.elite-markets.net/eddn/outfitting/1',
|
||||
'message' : {
|
||||
'systemName' : data['lastSystem']['name'].strip(),
|
||||
'stationName' : data['lastStarport']['name'].strip(),
|
||||
'modules' : modules,
|
||||
}
|
||||
})
|
||||
|
||||
def export_shipyard(data):
|
||||
# Don't send empty ships list - shipyard data is only guaranteed present if user has visited the shipyard.
|
||||
|
Loading…
x
Reference in New Issue
Block a user