Fix CREST stuff

This commit is contained in:
blitzmann
2017-11-05 01:28:57 -05:00
parent bd0de82a8e
commit cebca64e5e
4 changed files with 17 additions and 14 deletions

View File

@@ -15,6 +15,7 @@ from gui.display import Display
import gui.globalEvents as GE import gui.globalEvents as GE
from logbook import Logger from logbook import Logger
import calendar
pyfalog = Logger(__name__) pyfalog = Logger(__name__)
if 'wxMac' not in wx.PlatformInfo or ('wxMac' in wx.PlatformInfo and wx.VERSION >= (3, 0)): if 'wxMac' not in wx.PlatformInfo or ('wxMac' in wx.PlatformInfo and wx.VERSION >= (3, 0)):
@@ -112,7 +113,8 @@ class CrestFittings(wx.Frame):
def updateCacheStatus(self, event): def updateCacheStatus(self, event):
t = time.gmtime(self.cacheTime - time.time()) t = time.gmtime(self.cacheTime - time.time())
if t < 0:
if calendar.timegm(t) < 0: # calendar.timegm gets seconds until time given
self.cacheTimer.Stop() self.cacheTimer.Stop()
else: else:
sTime = time.strftime("%H:%M:%S", t) sTime = time.strftime("%H:%M:%S", t)
@@ -222,7 +224,7 @@ class ExportToEve(wx.Frame):
self.mainFrame.Bind(GE.EVT_SSO_LOGIN, self.ssoLogin) self.mainFrame.Bind(GE.EVT_SSO_LOGIN, self.ssoLogin)
self.Bind(wx.EVT_CLOSE, self.OnClose) self.Bind(wx.EVT_CLOSE, self.OnClose)
self.SetSizer(hSizer) self.SetSizer(mainSizer)
self.SetStatusBar(self.statusbar) self.SetStatusBar(self.statusbar)
self.Layout() self.Layout()

View File

@@ -614,7 +614,7 @@ class MainFrame(wx.Frame):
char = sCrest.implicitCharacter char = sCrest.implicitCharacter
if char: if char:
t = time.gmtime(char.eve.expires - time.time()) t = time.gmtime(char.eve.expires - time.time())
sTime = time.strftime("%H:%M:%S", t if t >= 0 else 0) sTime = time.strftime("%H:%M:%S", t)
newTitle = "%s | %s - %s" % (self.title, char.name, sTime) newTitle = "%s | %s - %s" % (self.title, char.name, sTime)
self.SetTitle(newTitle) self.SetTitle(newTitle)

View File

@@ -75,14 +75,15 @@ class Crest(object):
self.state = None self.state = None
self.ssoTimer = None self.ssoTimer = None
self.eve_options = {
'client_id': self.settings.get('clientID') if self.settings.get('mode') == CrestModes.USER else self.clientIDs.get(self.settings.get('server')),
'api_key': self.settings.get('clientSecret') if self.settings.get('mode') == CrestModes.USER else None,
'redirect_uri': self.clientCallback,
'testing': self.isTestServer
}
# Base EVE connection that is copied to all characters # Base EVE connection that is copied to all characters
self.eve = EVE( self.eve = EVE(**self.eve_options)
client_id=self.settings.get('clientID') if self.settings.get(
'mode') == CrestModes.USER else self.clientIDs.get(self.settings.get('server')),
api_key=self.settings.get('clientSecret') if self.settings.get('mode') == CrestModes.USER else None,
redirect_uri=self.clientCallback,
testing=self.isTestServer
)
self.implicitCharacter = None self.implicitCharacter = None
@@ -131,7 +132,7 @@ class Crest(object):
char = eos.db.getCrestCharacter(charID) char = eos.db.getCrestCharacter(charID)
if char and not hasattr(char, "eve"): if char and not hasattr(char, "eve"):
char.eve = copy.deepcopy(self.eve) char.eve = EVE(**self.eve_options)
char.eve.temptoken_authorize(refresh_token=char.refresh_token) char.eve.temptoken_authorize(refresh_token=char.refresh_token)
self.charCache[charID] = char self.charCache[charID] = char
return char return char
@@ -188,7 +189,7 @@ class Crest(object):
pyfalog.debug("Handling CREST login with: {0}", message) pyfalog.debug("Handling CREST login with: {0}", message)
if 'access_token' in message: # implicit if 'access_token' in message: # implicit
eve = copy.deepcopy(self.eve) eve = EVE(**self.eve_options)
eve.temptoken_authorize( eve.temptoken_authorize(
access_token=message['access_token'][0], access_token=message['access_token'][0],
expires_in=int(message['expires_in'][0]) expires_in=int(message['expires_in'][0])
@@ -207,7 +208,7 @@ class Crest(object):
wx.PostEvent(self.mainFrame, GE.SsoLogin(type=CrestModes.IMPLICIT)) wx.PostEvent(self.mainFrame, GE.SsoLogin(type=CrestModes.IMPLICIT))
elif 'code' in message: elif 'code' in message:
eve = copy.deepcopy(self.eve) eve = EVE(**self.eve_options)
eve.authorize(message['code'][0]) eve.authorize(message['code'][0])
eve() eve()
info = eve.whoami() info = eve.whoami()

View File

@@ -95,7 +95,7 @@ class AuthHandler(http.server.BaseHTTPRequestHandler):
finally: finally:
self.send_response(200) self.send_response(200)
self.end_headers() self.end_headers()
self.wfile.write(HTML.format(msg)) self.wfile.write(str.encode(HTML.format(msg)))
if step2: if step2:
# Only stop once if we've received something in the querystring # Only stop once if we've received something in the querystring