1
0
mirror of https://github.com/EDCD/EDMarketConnector.git synced 2025-06-08 11:22:10 +03:00

Added hooks into killswitches in plugins

This commit is contained in:
A_D 2020-10-18 08:51:34 +02:00 committed by Athanasius
parent 517a0e1f7c
commit d81093760e
3 changed files with 18 additions and 4 deletions

View File

@ -10,12 +10,13 @@ from collections import OrderedDict
from os import SEEK_SET from os import SEEK_SET
from os.path import join from os.path import join
from platform import system from platform import system
from typing import TYPE_CHECKING, Any, AnyStr, Dict, Iterator, List, Mapping, MutableMapping, Optional, Tuple from typing import TYPE_CHECKING, Any, AnyStr, Dict, Iterator, List, Mapping, MutableMapping, Optional
from typing import OrderedDict as OrderedDictT from typing import OrderedDict as OrderedDictT
from typing import Sequence, TextIO from typing import Sequence, TextIO, Tuple
import requests import requests
import killswitch
import myNotebook as nb # noqa: N813 import myNotebook as nb # noqa: N813
from companion import CAPIData, category_map from companion import CAPIData, category_map
from config import applongname, appversion, config from config import applongname, appversion, config
@ -25,7 +26,7 @@ from prefs import prefsVersion
from ttkHyperlinkLabel import HyperlinkLabel from ttkHyperlinkLabel import HyperlinkLabel
if sys.platform != 'win32': if sys.platform != 'win32':
from fcntl import lockf, LOCK_EX, LOCK_NB from fcntl import LOCK_EX, LOCK_NB, lockf
if TYPE_CHECKING: if TYPE_CHECKING:
@ -126,6 +127,10 @@ class EDDN:
:param cmdr: the CMDR to use as the uploader ID :param cmdr: the CMDR to use as the uploader ID
:param msg: the payload to send :param msg: the payload to send
""" """
if killswitch.is_disabled('plugins.eddn_send'):
logger.warning("eddn.send has been disabled via killswitch. Returning")
return
uploader_id = cmdr uploader_id = cmdr
to_send: OrderedDictT[str, str] = OrderedDict([ to_send: OrderedDictT[str, str] = OrderedDict([

View File

@ -19,6 +19,7 @@ from typing import TYPE_CHECKING, Any, List, Mapping, MutableMapping, Optional,
import requests import requests
import killswitch
import myNotebook as nb # noqa: N813 import myNotebook as nb # noqa: N813
import plug import plug
from config import applongname, appversion, config from config import applongname, appversion, config
@ -508,6 +509,10 @@ def worker() -> None:
logger.debug('Empty queue message, setting closing = True') logger.debug('Empty queue message, setting closing = True')
closing = True # Try to send any unsent events before we close closing = True # Try to send any unsent events before we close
if killswitch.is_disabled("plugins.eddn.worker"):
logger.warning('EDSM worker has been disabled via kill switch. Not uploading data.')
continue
retrying = 0 retrying = 0
while retrying < 3: while retrying < 3:
try: try:

View File

@ -1,6 +1,5 @@
"""Inara Sync.""" """Inara Sync."""
from companion import CAPIData
import dataclasses import dataclasses
import json import json
import sys import sys
@ -17,9 +16,11 @@ from typing import Sequence, Union, cast
import requests import requests
import killswitch
import myNotebook as nb # noqa: N813 import myNotebook as nb # noqa: N813
import plug import plug
import timeout_session import timeout_session
from companion import CAPIData
from config import applongname, appversion, config from config import applongname, appversion, config
from EDMCLogging import get_main_logger from EDMCLogging import get_main_logger
from ttkHyperlinkLabel import HyperlinkLabel from ttkHyperlinkLabel import HyperlinkLabel
@ -1202,6 +1203,9 @@ def new_worker():
logger.debug('Starting...') logger.debug('Starting...')
while True: while True:
events = get_events() events = get_events()
if killswitch.is_disabled("plugins.inara.worker"):
logger.warning("Inara worker disabled via killswitch")
return
for creds, event_list in events.items(): for creds, event_list in events.items():
if not event_list: if not event_list: