1
0
mirror of https://github.com/EDCD/EDMarketConnector.git synced 2025-04-17 17:42:20 +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.path import join
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 Sequence, TextIO
from typing import Sequence, TextIO, Tuple
import requests
import killswitch
import myNotebook as nb # noqa: N813
from companion import CAPIData, category_map
from config import applongname, appversion, config
@ -25,7 +26,7 @@ from prefs import prefsVersion
from ttkHyperlinkLabel import HyperlinkLabel
if sys.platform != 'win32':
from fcntl import lockf, LOCK_EX, LOCK_NB
from fcntl import LOCK_EX, LOCK_NB, lockf
if TYPE_CHECKING:
@ -126,6 +127,10 @@ class EDDN:
:param cmdr: the CMDR to use as the uploader ID
: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
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 killswitch
import myNotebook as nb # noqa: N813
import plug
from config import applongname, appversion, config
@ -508,6 +509,10 @@ def worker() -> None:
logger.debug('Empty queue message, setting closing = True')
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
while retrying < 3:
try:

View File

@ -1,6 +1,5 @@
"""Inara Sync."""
from companion import CAPIData
import dataclasses
import json
import sys
@ -17,9 +16,11 @@ from typing import Sequence, Union, cast
import requests
import killswitch
import myNotebook as nb # noqa: N813
import plug
import timeout_session
from companion import CAPIData
from config import applongname, appversion, config
from EDMCLogging import get_main_logger
from ttkHyperlinkLabel import HyperlinkLabel
@ -1202,6 +1203,9 @@ def new_worker():
logger.debug('Starting...')
while True:
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():
if not event_list: