mirror of
https://gitlab.com/allianceauth/allianceauth.git
synced 2026-02-12 18:16:24 +01:00
Change to on-demand loading for debug and failed starts only
This commit is contained in:
@@ -1,9 +1,16 @@
|
||||
from esi.clients import esi_client_factory
|
||||
from bravado.exception import HTTPNotFound, HTTPUnprocessableEntity
|
||||
import logging
|
||||
import os
|
||||
|
||||
SWAGGER_SPEC_PATH = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'swagger.json')
|
||||
from bravado.exception import HTTPNotFound, HTTPUnprocessableEntity, HTTPError
|
||||
from jsonschema.exceptions import RefResolutionError
|
||||
|
||||
from django.conf import settings
|
||||
from esi.clients import esi_client_factory
|
||||
|
||||
|
||||
SWAGGER_SPEC_PATH = os.path.join(os.path.dirname(
|
||||
os.path.abspath(__file__)), 'swagger.json'
|
||||
)
|
||||
"""
|
||||
Swagger spec operations:
|
||||
|
||||
@@ -151,7 +158,23 @@ class EveProvider(object):
|
||||
|
||||
class EveSwaggerProvider(EveProvider):
|
||||
def __init__(self, token=None, adapter=None):
|
||||
self._client = None
|
||||
if settings.DEBUG:
|
||||
self._client = None
|
||||
logger.info(
|
||||
'DEBUG mode detected: ESI client will be loaded on-demand.'
|
||||
)
|
||||
else:
|
||||
try:
|
||||
self._client = esi_client_factory(
|
||||
token=token, spec_file=SWAGGER_SPEC_PATH
|
||||
)
|
||||
except (HTTPError, RefResolutionError):
|
||||
logger.exception(
|
||||
'Failed to load ESI client on startup. '
|
||||
'Switching to on-demand loading for ESI client.'
|
||||
)
|
||||
self._client = None
|
||||
|
||||
self._token = token
|
||||
self.adapter = adapter or self
|
||||
|
||||
|
||||
Reference in New Issue
Block a user