From fe1c4cc4d4db5b65a909347780168d91c32d8323 Mon Sep 17 00:00:00 2001 From: blitzmann Date: Mon, 12 Feb 2018 21:43:23 -0500 Subject: [PATCH] Make a callback for token refresh, not sure how I'm gonna handle this one yet --- service/esi.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/service/esi.py b/service/esi.py index 5014c63c8..bf665470f 100644 --- a/service/esi.py +++ b/service/esi.py @@ -25,6 +25,8 @@ pyfalog = Logger(__name__) cache_path = os.path.join(config.savePath, config.ESI_CACHE) +from esipy.events import AFTER_TOKEN_REFRESH + if not os.path.exists(cache_path): os.mkdir(cache_path) @@ -69,6 +71,8 @@ class Esi(object): def __init__(self): Esi.initEsiApp() + AFTER_TOKEN_REFRESH.add_receiver(self.tokenUpdate) + self.settings = CRESTSettings.getInstance() # these will be set when needed @@ -86,6 +90,10 @@ class Esi(object): import gui.mainFrame # put this here to avoid loop self.mainFrame = gui.mainFrame.MainFrame.getInstance() + def tokenUpdate(self, **kwargs): + print(kwargs) + pass + @property def isTestServer(self): return self.settings.get('server') == Servers.SISI @@ -105,7 +113,9 @@ class Esi(object): char = eos.db.getSsoCharacter(id, config.getClientSecret()) if char is not None and char.esi_client is None: char.esi_client = Esi.genEsiClient() - char.esi_client.security.update_token(Esi.get_sso_data(char)) + Esi.update_token(char, Esi.get_sso_data(char)) # don't use update_token on security directly, se still need to apply the values here + print(repr(char)) + eos.db.commit() return char def getSkills(self, id):