From 04cf0c201a0076046f7d92bc931a2a1e4e057189 Mon Sep 17 00:00:00 2001 From: David Sangrey Date: Tue, 19 Sep 2023 20:03:08 -0400 Subject: [PATCH] 2051 Further Reversions from Silliness --- config/windows.py | 2 +- plug.py | 1 + plugins/eddn.py | 38 ++++++++++++++++++++------------------ plugins/edsm.py | 5 +++++ plugins/inara.py | 21 ++++++++++++--------- 5 files changed, 39 insertions(+), 28 deletions(-) diff --git a/config/windows.py b/config/windows.py index b51ace5b21..94a158f1d5 100644 --- a/config/windows.py +++ b/config/windows.py @@ -219,7 +219,7 @@ def set(self, key: str, val: Union[int, str, List[str], bool]) -> None: else: raise ValueError(f'Unexpected type for value {type(val)=}') - winreg.SetValueEx(self.__reg_handle, key, REG_RESERVED_ALWAYS_ZERO, reg_type, val) + winreg.SetValueEx(self.__reg_handle, key, REG_RESERVED_ALWAYS_ZERO, reg_type, val) # type: ignore def delete(self, key: str, *, suppress=False) -> None: """ diff --git a/plug.py b/plug.py index 4816e3569e..edfc4a74ca 100644 --- a/plug.py +++ b/plug.py @@ -170,6 +170,7 @@ def get_prefs( frame = plugin_prefs(parent, cmdr, is_beta) if isinstance(frame, nb.Frame): return frame + raise AssertionError # Intentionally throw an error here except Exception: logger.exception(f'Failed for Plugin "{self.name}"') return None diff --git a/plugins/eddn.py b/plugins/eddn.py index 27f7d51239..2158ecccee 100644 --- a/plugins/eddn.py +++ b/plugins/eddn.py @@ -461,26 +461,28 @@ def queue_check_and_send(self, reschedule: bool = False) -> None: # noqa: CCR00 :param reschedule: Boolean indicating if we should call `after()` again. """ logger.trace_if("plugin.eddn.send", "Called") - # Mutex in case we're already processing - if self.queue_processing.acquire(blocking=False): - logger.trace_if("plugin.eddn.send", "Obtained mutex") - - have_rescheduled = False - - if reschedule: - logger.trace_if("plugin.eddn.send", f"Next run scheduled for {self.eddn.REPLAY_PERIOD}ms from now") - self.eddn.parent.after(self.eddn.REPLAY_PERIOD, self.queue_check_and_send, reschedule) - have_rescheduled = True - - logger.trace_if("plugin.eddn.send", "Mutex released") - self.queue_processing.release() - else: + if not self.queue_processing.acquire(blocking=False): logger.trace_if("plugin.eddn.send", "Couldn't obtain mutex") - - if not reschedule: - logger.trace_if("plugin.eddn.send", "NO next run scheduled (there should be another one already set)") - + if reschedule: + logger.trace_if( + "plugin.eddn.send", + f"Next run scheduled for {self.eddn.REPLAY_PERIOD}ms from now", + ) + self.eddn.parent.after( + self.eddn.REPLAY_PERIOD, self.queue_check_and_send, reschedule + ) + + else: + logger.trace_if( + "plugin.eddn.send", + "NO next run scheduled (there should be another one already set)", + ) + + return + logger.trace_if("plugin.eddn.send", "Obtained mutex") + # Used to indicate if we've rescheduled at the faster rate already. + have_rescheduled = False # We send either if docked or 'Delay sending until docked' not set if this.docked or not config.get_int('output') & config.OUT_EDDN_DELAY: logger.trace_if("plugin.eddn.send", "Should send") diff --git a/plugins/edsm.py b/plugins/edsm.py index 1354869cf6..2ae2d8a77e 100644 --- a/plugins/edsm.py +++ b/plugins/edsm.py @@ -411,6 +411,8 @@ def set_prefs_ui_states(state: str) -> None: Set the state of various config UI entries. :param state: the state to set each entry to + + # NOTE: This may break things, watch out in testing. (5.10) """ elements = [ this.label, @@ -483,6 +485,7 @@ def credentials(cmdr: str) -> Optional[Tuple[str, str]]: if cmdr in cmdrs and len(cmdrs) == len(edsm_usernames) == len(edsm_apikeys): idx = cmdrs.index(cmdr) if idx < len(edsm_usernames) and idx < len(edsm_apikeys): + logger.trace_if(CMDR_CREDS, f'{cmdr=}: returning ({edsm_usernames[idx]=}, {edsm_apikeys[idx]=})') return edsm_usernames[idx], edsm_apikeys[idx] logger.trace_if(CMDR_CREDS, f'{cmdr=}: returning None') @@ -905,6 +908,8 @@ def worker() -> None: # noqa: CCR001 C901 last_game_version = game_version last_game_build = game_build + logger.debug("Done." + def should_send(entries: List[Mapping[str, Any]], event: str) -> bool: # noqa: CCR001 """ diff --git a/plugins/inara.py b/plugins/inara.py index b887c6633b..efe010df61 100644 --- a/plugins/inara.py +++ b/plugins/inara.py @@ -1330,7 +1330,7 @@ def journal_entry( # noqa: C901, CCR001 return '' # No error -def cmdr_data(data: CAPIData, is_beta): +def cmdr_data(data: CAPIData, is_beta): # noqa: CCR001, reanalyze me later """CAPI event hook.""" this.cmdr = data['commander']['name'] @@ -1339,15 +1339,10 @@ def cmdr_data(data: CAPIData, is_beta): this.station_marketid = data['commander']['docked'] and data['lastStarport']['id'] # Only trust CAPI if these aren't yet set - if not this.system_name: - this.system_name = data['lastSystem']['name'] + this.system_name = this.system_name if this.system_name else data['lastSystem']['name'] - if data['commander']['docked']: + if not this.station and data['commander']['docked']: this.station = data['lastStarport']['name'] - elif data['lastStarport']['name'] and data['lastStarport']['name'] != "": - this.station = STATION_UNDOCKED - else: - this.station = '' # Override standard URL functions if config.get_str('system_provider') == 'Inara': @@ -1357,7 +1352,15 @@ def cmdr_data(data: CAPIData, is_beta): this.system_link.update_idletasks() if config.get_str('station_provider') == 'Inara': - this.station_link['text'] = this.station + if data['commander']['docked'] or this.on_foot and this.station: + this.station_link['text'] = this.station + + elif data['lastStarport']['name'] and data['lastStarport']['name'] != "": + this.station_link['text'] = STATION_UNDOCKED + + else: + this.station_link['text'] = '' + # Do *NOT* set 'url' here, as it's set to a function that will call # through correctly. We don't want a static string. this.station_link.update_idletasks()