Skip to content

Commit

Permalink
2051 Further Reversions from Silliness
Browse files Browse the repository at this point in the history
  • Loading branch information
Rixxan committed Sep 20, 2023
1 parent 2386d01 commit 0f17c09
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 28 deletions.
2 changes: 1 addition & 1 deletion config/windows.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
"""
Expand Down
1 change: 1 addition & 0 deletions plug.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
38 changes: 20 additions & 18 deletions plugins/eddn.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
5 changes: 5 additions & 0 deletions plugins/edsm.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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')
Expand Down Expand Up @@ -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
"""
Expand Down
21 changes: 12 additions & 9 deletions plugins/inara.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']

Expand All @@ -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':
Expand All @@ -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()
Expand Down

0 comments on commit 0f17c09

Please sign in to comment.