Implement asynchronous api skill fetching
This commit is contained in:
@@ -657,14 +657,19 @@ class APIView(wx.Panel):
|
||||
def fetchSkills(self, event):
|
||||
charName = self.charChoice.GetString(self.charChoice.GetSelection())
|
||||
if charName:
|
||||
try:
|
||||
sChar = Character.getInstance()
|
||||
activeChar = self.charEditor.entityEditor.getActiveEntity()
|
||||
sChar.apiFetch(activeChar.ID, charName)
|
||||
self.stStatus.SetLabel("Successfully fetched %s\'s skills from EVE API." % charName)
|
||||
except Exception, e:
|
||||
pyfalog.error("Unable to retrieve {0}\'s skills. Error message:\n{1}", charName, e)
|
||||
self.stStatus.SetLabel("Unable to retrieve %s\'s skills. Error message:\n%s" % (charName, e))
|
||||
sChar = Character.getInstance()
|
||||
activeChar = self.charEditor.entityEditor.getActiveEntity()
|
||||
sChar.apiFetch(activeChar.ID, charName, self.__fetchCallback)
|
||||
self.stStatus.SetLabel("Getting skills for {}".format(charName))
|
||||
|
||||
def __fetchCallback(self, e=None):
|
||||
charName = self.charChoice.GetString(self.charChoice.GetSelection())
|
||||
if e is None:
|
||||
self.stStatus.SetLabel("Successfully fetched {}\'s skills from EVE API.".format(charName))
|
||||
else:
|
||||
exc_type, exc_obj, exc_trace = e
|
||||
pyfalog.error("Unable to retrieve {0}\'s skills. Error message:\n{1}".format(charName, exc_obj))
|
||||
self.stStatus.SetLabel("Unable to retrieve {}\'s skills. Error message:\n{}".format(charName, exc_obj))
|
||||
|
||||
|
||||
class SaveCharacterAs(wx.Dialog):
|
||||
|
||||
@@ -25,6 +25,7 @@ import gui.mainFrame
|
||||
from service.character import Character
|
||||
from service.fit import Fit
|
||||
from logbook import Logger
|
||||
|
||||
pyfalog = Logger(__name__)
|
||||
|
||||
|
||||
@@ -109,16 +110,24 @@ class CharacterSelection(wx.Panel):
|
||||
event.Skip()
|
||||
|
||||
def refreshApi(self, event):
|
||||
self.btnRefresh.Enable(False)
|
||||
sChar = Character.getInstance()
|
||||
ID, key, charName, chars = sChar.getApiDetails(self.getActiveCharacter())
|
||||
if charName:
|
||||
try:
|
||||
sChar.apiFetch(self.getActiveCharacter(), charName)
|
||||
except Exception as e:
|
||||
# can we do a popup, notifying user of API error?
|
||||
pyfalog.error("API fetch error")
|
||||
pyfalog.error(e)
|
||||
self.refreshCharacterList()
|
||||
sChar.apiFetch(self.getActiveCharacter(), charName, self.refreshAPICallback)
|
||||
|
||||
def refreshAPICallback(self, e=None):
|
||||
self.btnRefresh.Enable(True)
|
||||
if e is None:
|
||||
self.refreshCharacterList()
|
||||
else:
|
||||
exc_type, exc_obj, exc_trace = e
|
||||
pyfalog.warn("Error fetching API information for character")
|
||||
pyfalog.warn(exc_obj)
|
||||
|
||||
wx.MessageBox(
|
||||
"Error fetching API information, please check your API details in the character editor and try again later",
|
||||
"Error", wx.ICON_ERROR | wx.STAY_ON_TOP)
|
||||
|
||||
def charChanged(self, event):
|
||||
fitID = self.mainFrame.getActiveFit()
|
||||
|
||||
Reference in New Issue
Block a user