Get fitting browser to show up with proper characters (still not functional). Start testing ways to store the esipy app on the service (it can take a few seconds to initialize due to network calls)

This commit is contained in:
blitzmann
2018-02-07 01:21:22 -05:00
parent c7360c8cc3
commit eea8019593
5 changed files with 30 additions and 20 deletions

View File

@@ -34,16 +34,9 @@ class CrestFittings(wx.Frame):
characterSelectSizer = wx.BoxSizer(wx.HORIZONTAL)
if sCrest.settings.get('mode') == CrestModes.IMPLICIT:
self.stLogged = wx.StaticText(self, wx.ID_ANY, "Currently logged in as %s" % sCrest.implicitCharacter.name,
wx.DefaultPosition, wx.DefaultSize)
self.stLogged.Wrap(-1)
characterSelectSizer.Add(self.stLogged, 1, wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5)
else:
self.charChoice = wx.Choice(self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, [])
characterSelectSizer.Add(self.charChoice, 1, wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5)
self.updateCharList()
self.charChoice = wx.Choice(self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, [])
characterSelectSizer.Add(self.charChoice, 1, wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5)
self.updateCharList()
self.fetchBtn = wx.Button(self, wx.ID_ANY, "Fetch Fits", wx.DefaultPosition, wx.DefaultSize, 5)
characterSelectSizer.Add(self.fetchBtn, 0, wx.ALL, 5)
@@ -99,14 +92,14 @@ class CrestFittings(wx.Frame):
def updateCharList(self):
sCrest = Crest.getInstance()
chars = sCrest.getCrestCharacters()
chars = sCrest.getSsoCharacters()
if len(chars) == 0:
self.Close()
self.charChoice.Clear()
for char in chars:
self.charChoice.Append(char.name, char.ID)
self.charChoice.Append(char.characterName, char.characterID)
self.charChoice.SetSelection(0)
@@ -232,7 +225,7 @@ class ExportToEve(wx.Frame):
def updateCharList(self):
sCrest = Crest.getInstance()
chars = sCrest.getCrestCharacters()
chars = sCrest.getSsoCharacters()
if len(chars) == 0:
self.Close()
@@ -344,7 +337,7 @@ class CrestMgmt(wx.Dialog):
def popCharList(self):
sCrest = Crest.getInstance()
chars = sCrest.getCrestCharacters()
chars = sCrest.getSsoCharacters()
self.lcCharacters.DeleteAllItems()

View File

@@ -657,7 +657,7 @@ class MainFrame(wx.Frame):
menu.Enable(menu.exportToEveId, False)
else:
menu.SetLabel(menu.ssoLoginId, "Manage Characters")
enable = len(sCrest.getCrestCharacters()) == 0
enable = len(sCrest.getSsoCharacters()) == 0
menu.Enable(menu.eveFittingsId, not enable)
menu.Enable(menu.exportToEveId, not enable)

View File

@@ -145,8 +145,8 @@ class MainMenuBar(wx.MenuBar):
crestMenu.Append(self.exportToEveId, "Export To EVE")
# if self.sCrest.settings.get('mode') == CrestModes.IMPLICIT or len(self.sCrest.getCrestCharacters()) == 0:
self.Enable(self.eveFittingsId, False)
self.Enable(self.exportToEveId, False)
self.Enable(self.eveFittingsId, True)
self.Enable(self.exportToEveId, True)
if not self.mainFrame.disableOverrideEditor:
windowMenu.AppendSeparator()

View File

@@ -18,9 +18,11 @@ from service.server import StoppableHTTPServer, AuthHandler
from service.pycrest.eve import EVE
from .esi_security_proxy import EsiSecurityProxy
from esipy import EsiClient
from esipy import EsiClient, EsiApp
from esipy.cache import FileCache
import os
import logging
pyfalog = Logger(__name__)
@@ -41,6 +43,7 @@ class CrestModes(Enum):
IMPLICIT = 0
USER = 1
from utils.timer import Timer
class Crest(object):
clientIDs = {
@@ -54,6 +57,16 @@ class Crest(object):
_instance = None
@classmethod
def initEsiApp(cls):
with Timer() as t:
cls.esiapp = EsiApp(cache=None)
with Timer() as t:
cls.esi_v1 = cls.esiapp.get_v1_swagger
with Timer() as t:
cls.esi_v4 = cls.esiapp.get_v4_swagger
@classmethod
def genEsiClient(cls, security=None):
return EsiClient(
@@ -135,7 +148,7 @@ class Crest(object):
self.charCache = {}
wx.PostEvent(self.mainFrame, GE.SsoLogout(type=CrestModes.USER, numChars=0))
def getCrestCharacters(self):
def getSsoCharacters(self):
chars = eos.db.getSsoCharacters(config.getClientSecret())
return chars
@@ -150,6 +163,10 @@ class Crest(object):
def getFittings(self, charID):
char = self.getSsoCharacter(charID)
op = esi_v1.op['get_characters_character_id_fittings'](
character_id=self.currentCharacter.character_id
)
resp = self.currentCharacter.esi_client.request(op)
return char.eve.get('%scharacters/%d/fittings/' % (char.eve._authed_endpoint, char.ID))
def postFitting(self, charID, json):

View File

@@ -19,7 +19,7 @@ class Timer(object):
def checkpoint(self, name=''):
text = 'Timer - {timer} - {checkpoint} - {last:.2f}ms ({elapsed:.2f}ms elapsed)'.format(
timer=self.name,
checkpoint=str(name, "utf-8"),
checkpoint=name,
last=self.last,
elapsed=self.elapsed
).strip()