1
0
mirror of https://github.com/EDCD/EDMarketConnector.git synced 2025-04-14 08:17:13 +03:00

Handle empty shipyard at stations under repair

Fixes #296
This commit is contained in:
Jonathan Harris 2018-03-09 14:49:37 +00:00
parent 78dd0c5318
commit b3f6751a5b
3 changed files with 4 additions and 4 deletions

View File

@ -211,7 +211,7 @@ try:
data = data2
if args.s:
if data['lastStarport'].get('ships'):
if data['lastStarport'].get('ships', {}).get('shipyard_list'):
shipyard.export(data, args.s)
elif not args.j and monitor.stationservices and 'Shipyard' in monitor.stationservices:
sys.stderr.write("Failed to get shipyard data\n")

View File

@ -507,7 +507,7 @@ class AppWindow:
self.w.update_idletasks()
self.eddn.export_commodities(data, monitor.is_beta)
self.eddn.export_outfitting(data, monitor.is_beta)
if data['lastStarport'].get('ships'):
if data['lastStarport'].get('ships', {}).get('shipyard_list'):
self.eddn.export_shipyard(data, monitor.is_beta)
elif data['lastStarport'].get('services', {}).get('shipyard'):
# API is flakey about shipyard info - silently retry if missing (<1s is usually sufficient - 5s for margin).
@ -556,7 +556,7 @@ class AppWindow:
pass # might have undocked while we were waiting for retry in which case station data is unreliable
elif (data.get('lastSystem', {}).get('name') == monitor.system and
data.get('lastStarport', {}).get('name') == monitor.station and
data.get('lastStarport', {}).get('ships')):
data.get('lastStarport', {}).get('ships', {}).get('shipyard_list')):
self.eddn.export_shipyard(data, monitor.is_beta)
elif tries > 1: # bogus data - retry
self.w.after(int(SERVER_RETRY * 1000), lambda:self.retry_for_shipyard(tries-1))

View File

@ -212,7 +212,7 @@ class EDDN:
def export_shipyard(self, data, is_beta):
# Don't send empty ships list - shipyard data is only guaranteed present if user has visited the shipyard.
if data['lastStarport'].get('ships'):
if data['lastStarport'].get('ships', {}).get('shipyard_list'):
self.send(data['commander']['name'], {
'$schemaRef' : 'https://eddn.edcd.io/schemas/shipyard/2' + (is_beta and '/test' or ''),
'message' : OrderedDict([