From 9fd14a398067ea21d3a522312810639bd05886ea Mon Sep 17 00:00:00 2001 From: Athanasius Date: Tue, 6 Apr 2021 13:17:38 +0100 Subject: [PATCH] Inara: Don't send a setCommanderReputationMajorFaction if we have no Reputations Sure the `for k, v in ...` means not sending any that are empty/none, but it will still send the event, just with *no* reputations. When you're on a fresh character you have no reputations yet, so avoid causing an Inara API error, including status line text. Close #581 --- plugins/inara.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/plugins/inara.py b/plugins/inara.py index 4967737f..30b95cda 100644 --- a/plugins/inara.py +++ b/plugins/inara.py @@ -410,14 +410,16 @@ def journal_entry( ] ) - new_add_event( - 'setCommanderReputationMajorFaction', - entry['timestamp'], - [ - {'majorfactionName': k.lower(), 'majorfactionReputation': v / 100.0} - for k, v in state['Reputation'].items() if v is not None - ] - ) + # Don't send the API call with no values. + if state['Reputation']: + new_add_event( + 'setCommanderReputationMajorFaction', + entry['timestamp'], + [ + {'majorfactionName': k.lower(), 'majorfactionReputation': v / 100.0} + for k, v in state['Reputation'].items() if v is not None + ] + ) if state['Engineers']: # Not populated < 3.3 to_send: List[Mapping[str, Any]] = []