1
0
mirror of https://github.com/EDCD/EDMarketConnector.git synced 2025-04-17 17:42:20 +03:00

Added event disabling

You can now disable specific event handlers in plugins
This commit is contained in:
A_D 2020-10-29 14:44:32 +02:00 committed by Athanasius
parent 70087a27e4
commit 6374fbbeb8
5 changed files with 22 additions and 15 deletions

View File

@ -48,12 +48,9 @@ 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.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 |
| Kill Switch | Description |
| :--------------------------------------------------- | :------------------------------------------------------------------------------------------- |
| `plugins.eddn.send` | Disables all use of the send method on EDDN (effectively disables EDDN updates) |
| `plugins.(eddn|inara|edsm|eddb).journal` | Disables all journal processing for EDDN/EDSM/INARA |
| `plugins.(edsm|inara).worker` | Disables the EDSM/INARA worker thread (effectively disables updates) (does not close thread) |
| `plugins.(eddn|inara|edsm).journal.event.$eventname` | Specific events to disable processing for |

View File

@ -97,6 +97,9 @@ def journal_entry(cmdr, is_beta, system, station, entry, state):
logger.warning(f'Journal processing for EDDB has been disabled: {ks.reason}')
plug.show_error('EDDB Journal processing disabled. See Log')
return
elif (ks := killswitch.get_disabled(f'plugins.eddb.journal.event.{entry["event"]}')).disabled:
logger.warning(f'Processing of event {entry["event"]} has been disabled: {ks.reason}')
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

View File

@ -614,6 +614,9 @@ def journal_entry( # noqa: C901
logger.warning(f"EDDN journal handler has been disabled via killswitch: {ks.reason}")
plug.show_error("EDDN journal handler disabled. See Log.")
return
elif (ks := killswitch.get_disabled(f'plugins.eddn.journal.event{entry["name"]}')).disabled:
logger.warning(f'Handling of event {entry["name"]} disabled via killswitch: {ks.reason}')
return
# Recursively filter '*_Localised' keys from dict
def filter_localised(d: Mapping[str, Any]) -> OrderedDictT[str, Any]:

View File

@ -339,9 +339,12 @@ 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.")
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
elif (ks := killswitch.get_disabled(f'plugins.edsm.journal.event.{entry["name"]}')).disabled:
logger.warning(f'Handling of event {entry["name"]} has been disabled via killswitch: {ks.reason}')
return
if entry['event'] in ('CarrierJump', 'FSDJump', 'Location', 'Docked'):

View File

@ -322,10 +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.")
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
elif (ks := killswitch.get_disabled(f''))
event_name: str = entry['event']
this.cmdr = cmdr