diff --git a/docs/Killswitches.md b/docs/Killswitches.md index f4ea5145..d9b5930c 100644 --- a/docs/Killswitches.md +++ b/docs/Killswitches.md @@ -48,8 +48,12 @@ be used to query the kill switch set, see the docstrings for more information on ## Currently supported killswitch strings The current recognised (to EDMC and its internal plugins) killswitch strings are as follows: -| Kill Switch | Description | -| :--------------------- | :---------------------------------------------------------------------------------------- | -| `plugins.eddn.send` | Disables all use of the send method on EDDN (effectively disables EDDN updates) | -| `plugins.edsm.worker` | Disables the send portion of the EDSM worker thread (effectively disables EDSM updates) | -| `plugins.inara.worker` | Disables the send portion of the INARA worker thread (effectively disables INARA updates) | +| Kill Switch | Description | +| :---------------------- | :---------------------------------------------------------------------------------------- | +| `plugins.eddn.send` | Disables all use of the send method on EDDN (effectively disables EDDN updates) | +| `plugins.eddn.journal` | Disables all journal processing for EDDN | +| `plugins.edsm.worker` | Disables the send portion of the EDSM worker thread (effectively disables EDSM updates) | +| `plugins.edsm.journal` | Disables all journal processing for EDSM | +| `plugins.inara.worker` | Disables the send portion of the INARA worker thread (effectively disables INARA updates) | +| `plugins.inara.journal` | Disables all journal processing for INARA | +| `plugins.eddn.journal` | Disables all journal processing for EDDN | diff --git a/plugins/eddb.py b/plugins/eddb.py index 12ebc8ed..bd6b154f 100644 --- a/plugins/eddb.py +++ b/plugins/eddb.py @@ -23,17 +23,24 @@ # -from companion import CAPIData import sys -from typing import Any, Optional, TYPE_CHECKING +from typing import TYPE_CHECKING, Any, Optional + import requests +import EDMCLogging +import killswitch +import plug +from companion import CAPIData from config import config if TYPE_CHECKING: from tkinter import Tk +logger = EDMCLogging.get_main_logger() + + STATION_UNDOCKED: str = '×' # "Station" name to display when not docked = U+00D7 this: Any = sys.modules[__name__] # For holding module globals @@ -64,6 +71,7 @@ def station_url(system_name: str, station_name: str) -> str: return system_url(system_name) + def plugin_start3(plugin_dir): return 'eddb' @@ -83,7 +91,13 @@ def prefs_changed(cmdr, is_beta): # through correctly. We don't want a static string. pass + def journal_entry(cmdr, is_beta, system, station, entry, state): + if (ks := killswitch.get_disabled('plugins.eddb.journal')).disabled: + logger.warning(f'Journal processing for EDDB has been disabled: {ks.reason}') + plug.show_error('EDDB Journal processing disabled. See Log') + return + # Always update our system address even if we're not currently the provider for system or station, but dont update # on events that contain "future" data, such as FSDTarget if entry['event'] in ('Location', 'Docked', 'CarrierJump', 'FSDJump'): diff --git a/plugins/eddn.py b/plugins/eddn.py index 1fcde025..eac1b0d3 100644 --- a/plugins/eddn.py +++ b/plugins/eddn.py @@ -18,6 +18,7 @@ import requests import killswitch import myNotebook as nb # noqa: N813 +import plug from companion import CAPIData, category_map from config import applongname, appversion, config from EDMCLogging import get_main_logger @@ -609,6 +610,11 @@ def plugin_stop() -> None: def journal_entry( # noqa: C901 cmdr: str, is_beta: bool, system: str, station: str, entry: MutableMapping[str, Any], state: Mapping[str, Any] ) -> Optional[str]: + if (ks := killswitch.get_disabled("plugins.eddn.journal")).disabled: + logger.warning(f"EDDN journal handler has been disabled via killswitch: {ks.reason}") + plug.show_error("EDDN journal handler disabled. See Log.") + return + # Recursively filter '*_Localised' keys from dict def filter_localised(d: Mapping[str, Any]) -> OrderedDictT[str, Any]: filtered: OrderedDictT[str, Any] = OrderedDict() diff --git a/plugins/edsm.py b/plugins/edsm.py index 306c20e4..970b26f2 100644 --- a/plugins/edsm.py +++ b/plugins/edsm.py @@ -339,6 +339,11 @@ def journal_entry( cmdr: str, is_beta: bool, system: str, station: str, entry: MutableMapping[str, Any], state: Mapping[str, Any] ) -> None: """Journal Entry hook.""" + if (ks := killswitch.get_disabled("plugins.edsm.journal")).disabled: + logger.warning(f"EDSM Journal handler disabled via killswitch: {ks.reason}") + plug.show_error("EDSM Handler disabled. See Log.") + return + if entry['event'] in ('CarrierJump', 'FSDJump', 'Location', 'Docked'): logger.trace(f'''{entry["event"]} Commander: {cmdr} diff --git a/plugins/inara.py b/plugins/inara.py index 1543be1b..729e4b9e 100644 --- a/plugins/inara.py +++ b/plugins/inara.py @@ -322,6 +322,11 @@ def journal_entry( cmdr: str, is_beta: bool, system: str, station: str, entry: Dict[str, Any], state: Dict[str, Any] ) -> None: """Journal entry hook.""" + if (ks := killswitch.get_disabled("plugins.inara.journal")).disabled: + logger.warning(f"INARA support has been disabled via killswitch: {ks.reason}") + plug.show_error("INARA disabled. See Log.") + return + event_name: str = entry['event'] this.cmdr = cmdr this.FID = state['FID']