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

updated eddn to new killswitches

This commit is contained in:
A_D 2021-08-17 19:37:26 +02:00
parent f62f1ee97b
commit 6c7245ee3d
No known key found for this signature in database
GPG Key ID: 4BE9EB7DF45076C4
2 changed files with 13 additions and 7 deletions

View File

@ -92,7 +92,7 @@ The current recognised (to EDMC and its internal plugins) killswitch strings are
| Kill Switch | Supported Plugins | Description |
| :------------------------------------------- | :---------------------: | :---------------------------------------------------------------------------------------- |
| *`plugins.eddn.send` | eddn | Disables all use of the send method on EDDN (effectively disables EDDN updates) |
| `plugins.eddn.send` | eddn | Disables all use of the send method on EDDN (effectively disables EDDN updates) |
| `plugins.<plugin>.journal` | eddn, inara, edsm, eddb | Disables all journal processing for the plugin |
| `plugins.<plugin>.worker` | edsm, inara | Disables the plugins worker thread (effectively disables updates) (does not close thread) |
| `plugins.<plugin>.worker.<eventname>` | edsm, inara | Disables the plugin worker for the given eventname |

View File

@ -168,10 +168,13 @@ class EDDN:
:param cmdr: the CMDR to use as the uploader ID.
:param msg: the payload to send.
"""
if (res := killswitch.get_disabled('plugins.eddn.send')).disabled:
logger.warning(f"eddn.send has been disabled via killswitch. Returning. ({res.reason})")
should_return, new_data = killswitch.check_killswitch('plugins.eddn.send', msg)
if should_return:
logger.warning('eddn.send has been disabled via killswitch. Returning.')
return
msg = new_data
uploader_id = cmdr
to_send: OrderedDictT[str, OrderedDict[str, Any]] = OrderedDict([
@ -787,15 +790,18 @@ def journal_entry( # noqa: C901, CCR001
:param state: `dict` - Current `monitor.state` data.
:return: `str` - Error message, or `None` if no errors.
"""
if (ks := killswitch.get_disabled("plugins.eddn.journal")).disabled:
logger.warning(f'EDDN journal handler has been disabled via killswitch: {ks.reason}')
should_return, new_data = killswitch.check_killswitch('plugins.eddn.journal', entry)
if should_return:
plug.show_error(_('EDDN journal handler disabled. See Log.')) # LANG: Killswitch disabled EDDN
return None
elif (ks := killswitch.get_disabled(f'plugins.eddn.journal.event.{entry["event"]}')).disabled:
logger.warning(f'Handling of event {entry["event"]} disabled via killswitch: {ks.reason}')
should_return, new_data = killswitch.check_killswitch(f'plugins.eddn.journal.event.{entry["event"]}', new_data)
if should_return:
return None
entry = new_data
# Recursively filter '*_Localised' keys from dict
def filter_localised(d: Mapping[str, Any]) -> OrderedDictT[str, Any]:
filtered: OrderedDictT[str, Any] = OrderedDict()