From f6777f0237e146d25922987007ab113fb357c8e6 Mon Sep 17 00:00:00 2001 From: Athanasius Date: Fri, 4 Jun 2021 18:45:43 +0100 Subject: [PATCH] Inara: Only ApproachSettlement if we have system & fix key case * If you're near a settlement on login you get an ApproachSettlement before `monitor` has system set to pass into `journal_entry()`. * We had a case-type of an Inara API key, so it wasn't setting the BodyName. * TRACE level logging of what we actually send to Inara. --- plugins/inara.py | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/plugins/inara.py b/plugins/inara.py index d35dc944..86867aff 100644 --- a/plugins/inara.py +++ b/plugins/inara.py @@ -630,14 +630,17 @@ def journal_entry( # noqa: C901, CCR001 new_add_event('setCommanderTravelLocation', entry['timestamp'], to_send) elif event_name == 'ApproachSettlement': - to_send = { - 'starsystemName': system, - 'stationName': entry['Name'], - 'marketid': entry['MarketID'], - 'starsystemBodyName': entry['BodyName'], - 'starsystemBodyCoords': [entry['Latitude'], entry['Longitude']] - } - new_add_event('setCommanderTravelLocation', entry['timestamp'], to_send) + # If you're near a Settlement on login this event is recorded, but + # we might not yet have system logged for use. + if system: + to_send = { + 'starsystemName': system, + 'stationName': entry['Name'], + 'marketid': entry['MarketID'], + 'starsystemBodyName': entry['BodyName'], + 'starsystemBodyCoords': [entry['Latitude'], entry['Longitude']] + } + new_add_event('setCommanderTravelLocation', entry['timestamp'], to_send) elif event_name == 'FSDJump': this.undocked = False @@ -1197,7 +1200,7 @@ def journal_entry( # noqa: C901, CCR001 # These were included thus we are landed to_send['starsystemBodyCoords'] = [entry['Latitude'], entry['Longitude']] # if we're not Docked, but have these, we're either landed or close enough that it doesn't matter. - to_send['starSystemBodyName'] = entry['Body'] + to_send['starsystemBodyName'] = entry['Body'] new_add_event('setCommanderTravelLocation', entry['timestamp'], to_send) @@ -1483,6 +1486,7 @@ def new_worker(): ] } logger.info(f'sending {len(data["events"])} events for {creds.cmdr}') + logger.trace(f'Events:\n{json.dumps(data)}\n') try_send_data(TARGET_URL, data) time.sleep(WORKER_WAIT_TIME)