More work on getting fittings form a character via ESI. It's starting to be come a pain working with this client with having to background it until it initializes. Thinking about rolling my own, considering we only need a few calls and not a whole package.
This commit is contained in:
@@ -34,6 +34,9 @@ if not os.path.exists(cache_path):
|
||||
|
||||
file_cache = FileCache(cache_path)
|
||||
|
||||
esiRdy = threading.Event()
|
||||
|
||||
|
||||
class Servers(Enum):
|
||||
TQ = 0
|
||||
SISI = 1
|
||||
@@ -45,6 +48,17 @@ class CrestModes(Enum):
|
||||
|
||||
from utils.timer import Timer
|
||||
|
||||
|
||||
|
||||
class EsiInitThread(threading.Thread):
|
||||
def __init__(self):
|
||||
threading.Thread.__init__(self)
|
||||
self.name = "EsiInitThread"
|
||||
|
||||
def run(self):
|
||||
Crest.initEsiApp()
|
||||
|
||||
|
||||
class Crest(object):
|
||||
clientIDs = {
|
||||
Servers.TQ : 'f9be379951c046339dc13a00e6be7704',
|
||||
@@ -67,6 +81,8 @@ class Crest(object):
|
||||
with Timer() as t:
|
||||
cls.esi_v4 = cls.esiapp.get_v4_swagger
|
||||
|
||||
esiRdy.set()
|
||||
|
||||
@classmethod
|
||||
def genEsiClient(cls, security=None):
|
||||
return EsiClient(
|
||||
@@ -103,6 +119,10 @@ class Crest(object):
|
||||
characters still in the cache (if USER mode)
|
||||
"""
|
||||
|
||||
prefetch = EsiInitThread()
|
||||
prefetch.daemon = True
|
||||
prefetch.start()
|
||||
|
||||
self.settings = CRESTSettings.getInstance()
|
||||
self.scopes = ['characterFittingsRead', 'characterFittingsWrite']
|
||||
|
||||
@@ -159,15 +179,16 @@ class Crest(object):
|
||||
char = eos.db.getSsoCharacter(charID, config.getClientSecret())
|
||||
if char.esi_client is None:
|
||||
char.esi_client = Crest.genEsiClient()
|
||||
char.esi_client.security.update_token(char.get_sso_data())
|
||||
return char
|
||||
|
||||
def getFittings(self, charID):
|
||||
char = self.getSsoCharacter(charID)
|
||||
op = esi_v1.op['get_characters_character_id_fittings'](
|
||||
character_id=self.currentCharacter.character_id
|
||||
op = Crest.esi_v1.op['get_characters_character_id_fittings'](
|
||||
character_id=charID
|
||||
)
|
||||
resp = self.currentCharacter.esi_client.request(op)
|
||||
return char.eve.get('%scharacters/%d/fittings/' % (char.eve._authed_endpoint, char.ID))
|
||||
resp = char.esi_client.request(op)
|
||||
return resp
|
||||
|
||||
def postFitting(self, charID, json):
|
||||
# @todo: new fitting ID can be recovered from Location header,
|
||||
|
||||
Reference in New Issue
Block a user