diff --git a/eos/gamedata.py b/eos/gamedata.py index a55ff3baa..345290c37 100644 --- a/eos/gamedata.py +++ b/eos/gamedata.py @@ -461,9 +461,10 @@ class Item(EqBase): @property def price(self): - # todo: use `from sqlalchemy import inspect` instead (need to verify it works in old and new OS X builds) - if self.__price is not None and getattr(self.__price, '_sa_instance_state', None): - pyfalog.debug("Price data for {} was deleted, resetting object".format(self.ID)) + + # todo: use `from sqlalchemy import inspect` instead (mac-deprecated doesn't have inspect(), was imp[lemented in 0.8) + if self.__price is not None and getattr(self.__price, '_sa_instance_state', None) and self.__price._sa_instance_state.deleted: + pyfalog.debug("Price data for {} was deleted (probably from a cache reset), resetting object".format(self.ID)) self.__price = None if self.__price is None: diff --git a/gui/builtinViewColumns/price.py b/gui/builtinViewColumns/price.py index 5d43dabdc..3797052a2 100644 --- a/gui/builtinViewColumns/price.py +++ b/gui/builtinViewColumns/price.py @@ -45,8 +45,7 @@ class Price(ViewColumn): if stuff.isEmpty: return "" - sPrice = ServicePrice.getInstance() - price = sPrice.getPriceNow(stuff.item) + price = stuff.item.price.price if not price: return "" @@ -60,7 +59,7 @@ class Price(ViewColumn): sPrice = ServicePrice.getInstance() def callback(item): - price = sPrice.getPriceNow(item.ID) + price = item.item.price text = formatAmount(price.price, 3, 3, 9, currency=True) if price.price else "" if price.failed: text += " (!)" diff --git a/gui/builtinViews/fittingView.py b/gui/builtinViews/fittingView.py index 2c694289b..ff8bb4bf6 100644 --- a/gui/builtinViews/fittingView.py +++ b/gui/builtinViews/fittingView.py @@ -481,6 +481,7 @@ class FittingView(d.Display): # This only happens when turning on/off slot divisions self.populate(self.mods) self.refresh(self.mods) + self.Refresh() self.Show(self.activeFitID is not None and self.activeFitID == event.fitID) except wx._core.PyDeadObjectError: diff --git a/gui/itemStats.py b/gui/itemStats.py index bb940c653..677e1aa0f 100644 --- a/gui/itemStats.py +++ b/gui/itemStats.py @@ -535,6 +535,10 @@ class ItemParams(wx.Panel): class ItemCompare(wx.Panel): def __init__(self, parent, stuff, item, items, context=None): + # Start dealing with Price stuff to get that thread going + sPrice = ServicePrice.getInstance() + sPrice.getPrices(items, self.UpdateList) + wx.Panel.__init__(self, parent) mainSizer = wx.BoxSizer(wx.VERTICAL) @@ -591,11 +595,10 @@ class ItemCompare(wx.Panel): wx.DefaultSize, 0) bSizer.Add(self.toggleViewBtn, 0, wx.ALIGN_CENTER_VERTICAL) - if stuff is not None: - self.refreshBtn = wx.Button(self, wx.ID_ANY, u"Refresh", wx.DefaultPosition, wx.DefaultSize, - wx.BU_EXACTFIT) - bSizer.Add(self.refreshBtn, 0, wx.ALIGN_CENTER_VERTICAL) - self.refreshBtn.Bind(wx.EVT_BUTTON, self.RefreshValues) + self.refreshBtn = wx.Button(self, wx.ID_ANY, u"Refresh", wx.DefaultPosition, wx.DefaultSize, + wx.BU_EXACTFIT) + bSizer.Add(self.refreshBtn, 0, wx.ALIGN_CENTER_VERTICAL) + self.refreshBtn.Bind(wx.EVT_BUTTON, self.RefreshValues) mainSizer.Add(bSizer, 0, wx.ALIGN_RIGHT) @@ -610,7 +613,8 @@ class ItemCompare(wx.Panel): self.PopulateList(event.Column) self.Thaw() - def UpdateList(self): + def UpdateList(self, items=None): + # We do nothing with `items`, but it gets returned by the price service thread self.Freeze() self.paramList.ClearAll() self.PopulateList() @@ -680,9 +684,8 @@ class ItemCompare(wx.Panel): self.paramList.SetStringItem(i, x + 1, valueUnit) - # Add prices - sPrice = ServicePrice.getInstance() - self.paramList.SetStringItem(i, len(self.attrs) + 1, formatAmount(sPrice.getPriceNow(item), 3, 3, 9, currency=True)) + # Add prices + self.paramList.SetStringItem(i, len(self.attrs) + 1, formatAmount(item.price.price, 3, 3, 9, currency=True)) self.paramList.RefreshRows() self.Layout() @@ -1431,10 +1434,9 @@ class ItemProperties(wx.Panel): else: attrName = name.title() value = getattr(self.item, name) - except Exception as e: + except: # TODO: Add logging to this. # We couldn't get a property for some reason. Skip it for now. - print(e) continue index = self.paramList.InsertStringItem(sys.maxint, attrName) diff --git a/gui/mainFrame.py b/gui/mainFrame.py index 8a66e78d2..5e1ad08c6 100644 --- a/gui/mainFrame.py +++ b/gui/mainFrame.py @@ -255,7 +255,9 @@ class MainFrame(wx.Frame): # Remove any fits that cause exception when fetching (non-existent fits) for id in fits[:]: try: - sFit.getFit(id, basic=True) + fit = sFit.getFit(id, basic=True) + if fit is None: + fits.remove(id) except: fits.remove(id)