1
0
mirror of https://github.com/EDCD/EDMarketConnector.git synced 2025-04-16 09:10:35 +03:00

CAPI: Fix dump_capi_data() for /fleetcarrier

Still produces the system/station:

    `HIP 10792.Crimson Exchange.2022-12-30T16.22.39.json`

But now also the FC:

    `FleetCarrier.X3F-N5Z.2022-12-30T16.24.01.json`
This commit is contained in:
Athanasius 2022-12-30 16:25:25 +00:00
parent 74b070ffe9
commit 0fe5e17b65
No known key found for this signature in database
GPG Key ID: 772697E181BB2767

View File

@ -1125,24 +1125,27 @@ class Session(object):
def dump_capi_data(self, data: CAPIData) -> None:
"""Dump CAPI data to file for examination."""
if os.path.isdir('dump'):
try:
system = data['lastSystem']['name']
file_name: str = ""
if data.source_endpoint == self.FRONTIER_CAPI_PATH_FLEETCARRIER:
file_name += f"FleetCarrier.{data['name']['callsign']}"
except (KeyError, ValueError):
system = '<unknown system>'
else:
try:
file_name += data['lastSystem']['name']
try:
if data['commander'].get('docked'):
station = f'.{data["lastStarport"]["name"]}'
except (KeyError, ValueError):
file_name += 'unknown system'
else:
station = ''
try:
if data['commander'].get('docked'):
file_name += f'.{data["lastStarport"]["name"]}'
except (KeyError, ValueError):
station = '<unknown station>'
except (KeyError, ValueError):
file_name += '.unknown station'
timestamp = time.strftime('%Y-%m-%dT%H.%M.%S', time.localtime())
with open(f'dump/{system}{station}.{timestamp}.json', 'wb') as h:
file_name += time.strftime('.%Y-%m-%dT%H.%M.%S', time.localtime())
file_name += '.json'
with open(f'dump/{file_name}', 'wb') as h:
h.write(json.dumps(data, cls=CAPIDataEncoder,
ensure_ascii=False,
indent=2,