mirror of
https://gitlab.com/allianceauth/allianceauth.git
synced 2025-07-09 12:30:15 +02:00
use new user-agent generator, drop specfile
This commit is contained in:
parent
daaffaeabc
commit
6452b082a8
@ -1,6 +1,7 @@
|
|||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
from bravado.client import SwaggerClient
|
||||||
from bravado.exception import HTTPError, HTTPNotFound, HTTPUnprocessableEntity
|
from bravado.exception import HTTPError, HTTPNotFound, HTTPUnprocessableEntity
|
||||||
from jsonschema.exceptions import RefResolutionError
|
from jsonschema.exceptions import RefResolutionError
|
||||||
|
|
||||||
@ -8,7 +9,7 @@ from django.conf import settings
|
|||||||
|
|
||||||
from esi.clients import esi_client_factory
|
from esi.clients import esi_client_factory
|
||||||
|
|
||||||
from allianceauth import __version__
|
from allianceauth import __version__, __title__, __url__
|
||||||
from allianceauth.utils.django import StartupCommand
|
from allianceauth.utils.django import StartupCommand
|
||||||
|
|
||||||
SWAGGER_SPEC_PATH = os.path.join(os.path.dirname(
|
SWAGGER_SPEC_PATH = os.path.join(os.path.dirname(
|
||||||
@ -175,34 +176,19 @@ class EveProvider:
|
|||||||
|
|
||||||
|
|
||||||
class EveSwaggerProvider(EveProvider):
|
class EveSwaggerProvider(EveProvider):
|
||||||
def __init__(self, token=None, adapter=None):
|
def __init__(self, token=None, adapter=None) -> None:
|
||||||
if settings.DEBUG or StartupCommand().is_management_command:
|
|
||||||
self._client = None
|
|
||||||
logger.info('ESI client will be loaded on-demand')
|
|
||||||
else:
|
|
||||||
logger.info('Loading ESI client')
|
|
||||||
try:
|
|
||||||
self._client = esi_client_factory(
|
|
||||||
token=token,
|
|
||||||
spec_file=SWAGGER_SPEC_PATH,
|
|
||||||
app_info_text=f"allianceauth v{__version__}"
|
|
||||||
)
|
|
||||||
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._token = token
|
||||||
self.adapter = adapter or self
|
self.adapter = adapter or self
|
||||||
self._faction_list = None # what are the odds this will change? could cache forever!
|
self._faction_list = None # what are the odds this will change? could cache forever!
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def client(self):
|
def client(self) -> SwaggerClient:
|
||||||
if self._client is None:
|
if self._client is None:
|
||||||
self._client = esi_client_factory(
|
self._client = esi_client_factory(
|
||||||
token=self._token, spec_file=SWAGGER_SPEC_PATH, app_info_text=("allianceauth v" + __version__)
|
token=self._token,
|
||||||
|
ua_appname=__title__,
|
||||||
|
ua_version=__version__,
|
||||||
|
ua_url=__url__,
|
||||||
)
|
)
|
||||||
return self._client
|
return self._client
|
||||||
|
|
||||||
|
File diff suppressed because one or more lines are too long
@ -2,7 +2,7 @@ import os
|
|||||||
|
|
||||||
from esi.clients import EsiClientProvider
|
from esi.clients import EsiClientProvider
|
||||||
|
|
||||||
from allianceauth import __version__
|
from allianceauth import __version__, __title__, __url__
|
||||||
|
|
||||||
SWAGGER_SPEC = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'swagger.json')
|
SWAGGER_SPEC = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'swagger.json')
|
||||||
|
|
||||||
@ -12,8 +12,8 @@ get_killmails_killmail_id_killmail_hash
|
|||||||
get_universe_types_type_id
|
get_universe_types_type_id
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
esi = EsiClientProvider(
|
esi = EsiClientProvider(
|
||||||
spec_file=SWAGGER_SPEC,
|
ua_appname=__title__,
|
||||||
app_info_text=("allianceauth v" + __version__)
|
ua_version=__version__,
|
||||||
|
ua_url=__url__,
|
||||||
)
|
)
|
||||||
|
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user