mirror of
https://github.com/EDCD/EDMarketConnector.git
synced 2025-06-09 11:52:27 +03:00
companion: A start on adding CAPI killswitches
This commit is contained in:
parent
a9ff256afd
commit
f789ad6e24
18
companion.py
18
companion.py
@ -28,6 +28,7 @@ from typing import TYPE_CHECKING, Any, Dict, List, Mapping, Optional, OrderedDic
|
|||||||
import requests
|
import requests
|
||||||
|
|
||||||
import config as conf_module
|
import config as conf_module
|
||||||
|
import killswitch
|
||||||
import protocol
|
import protocol
|
||||||
from config import config, user_agent
|
from config import config, user_agent
|
||||||
from edmc_data import companion_category_map as category_map
|
from edmc_data import companion_category_map as category_map
|
||||||
@ -325,6 +326,11 @@ class Auth(object):
|
|||||||
"""
|
"""
|
||||||
logger.debug(f'Trying for "{self.cmdr}"')
|
logger.debug(f'Trying for "{self.cmdr}"')
|
||||||
|
|
||||||
|
should_return, new_data = killswitch.check_killswitch('capi.auth', {})
|
||||||
|
if should_return:
|
||||||
|
logger.warning('capi.auth has been disabled via killswitch. Returning.')
|
||||||
|
return None
|
||||||
|
|
||||||
self.verifier = None
|
self.verifier = None
|
||||||
cmdrs = config.get_list('cmdrs', default=[])
|
cmdrs = config.get_list('cmdrs', default=[])
|
||||||
logger.debug(f'Cmdrs: {cmdrs}')
|
logger.debug(f'Cmdrs: {cmdrs}')
|
||||||
@ -393,9 +399,11 @@ class Auth(object):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
def authorize(self, payload: str) -> str: # noqa: CCR001
|
def authorize(self, payload: str) -> str: # noqa: CCR001
|
||||||
"""Handle oAuth authorization callback.
|
"""
|
||||||
|
Handle oAuth authorization callback.
|
||||||
|
|
||||||
:return: access token if successful, otherwise raises CredentialsError.
|
:return: access token if successful
|
||||||
|
:raises CredentialsError
|
||||||
"""
|
"""
|
||||||
logger.debug('Checking oAuth authorization callback')
|
logger.debug('Checking oAuth authorization callback')
|
||||||
if '?' not in payload:
|
if '?' not in payload:
|
||||||
@ -655,6 +663,11 @@ class Session(object):
|
|||||||
|
|
||||||
:return: True if login succeeded, False if re-authorization initiated.
|
:return: True if login succeeded, False if re-authorization initiated.
|
||||||
"""
|
"""
|
||||||
|
should_return, new_data = killswitch.check_killswitch('capi.auth', {})
|
||||||
|
if should_return:
|
||||||
|
logger.warning('capi.auth has been disabled via killswitch. Returning.')
|
||||||
|
return False
|
||||||
|
|
||||||
if not Auth.CLIENT_ID:
|
if not Auth.CLIENT_ID:
|
||||||
logger.error('self.CLIENT_ID is None')
|
logger.error('self.CLIENT_ID is None')
|
||||||
raise CredentialsError('cannot login without a valid Client ID')
|
raise CredentialsError('cannot login without a valid Client ID')
|
||||||
@ -946,6 +959,7 @@ class Session(object):
|
|||||||
# event too, so assume it will be polling the response queue.
|
# event too, so assume it will be polling the response queue.
|
||||||
if query.tk_response_event is not None:
|
if query.tk_response_event is not None:
|
||||||
logger.trace_if('capi.worker', 'Sending <<CAPIResponse>>')
|
logger.trace_if('capi.worker', 'Sending <<CAPIResponse>>')
|
||||||
|
if self.tk_master is not None:
|
||||||
self.tk_master.event_generate('<<CAPIResponse>>')
|
self.tk_master.event_generate('<<CAPIResponse>>')
|
||||||
|
|
||||||
logger.info('CAPI worker thread DONE')
|
logger.info('CAPI worker thread DONE')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user