From e971b7927e0bedb7761344e7dd37417befbbc37a Mon Sep 17 00:00:00 2001 From: blitzmann Date: Fri, 21 Apr 2017 00:40:45 -0400 Subject: [PATCH 1/7] Fix issue in which prices are removed all the time (forgot to add the check for deleted to the condition >.<) --- eos/gamedata.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/eos/gamedata.py b/eos/gamedata.py index 8700229dc..e943c8b48 100644 --- a/eos/gamedata.py +++ b/eos/gamedata.py @@ -444,8 +444,11 @@ class Item(EqBase): 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)) + + + + 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: From 711537dcf4c70a73243988ad146bcc84536d82d7 Mon Sep 17 00:00:00 2001 From: blitzmann Date: Fri, 21 Apr 2017 00:45:36 -0400 Subject: [PATCH 2/7] Change to using inspect() instead of the current shitty way --- eos/gamedata.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/eos/gamedata.py b/eos/gamedata.py index e943c8b48..d12940a8a 100644 --- a/eos/gamedata.py +++ b/eos/gamedata.py @@ -20,6 +20,7 @@ import re from sqlalchemy.orm import reconstructor +from sqlalchemy import inspect import eos.db from eqBase import EqBase @@ -443,11 +444,9 @@ 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) and self.__price._sa_instance_state.deleted: + # This happens when the price record is deleted from the database. We dynamically refresh the price object + # attached to the fit if it's determined to have been deleted + if self.__price is not None and inspect(self.__price).deleted: pyfalog.debug("Price data for {} was deleted (probably from a cache reset), resetting object".format(self.ID)) self.__price = None From 0079f76f679683d6bca6cd97d42bd2f2ee52efa5 Mon Sep 17 00:00:00 2001 From: Ebag333 Date: Thu, 13 Apr 2017 12:00:16 -0700 Subject: [PATCH 3/7] Change price column to use new method --- gui/builtinViewColumns/price.py | 5 ++--- gui/builtinViews/fittingView.py | 1 + 2 files changed, 3 insertions(+), 3 deletions(-) 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: From 4652b91e980cd76cac37ad0813e1c6bb0a8d7535 Mon Sep 17 00:00:00 2001 From: Ebag333 Date: Thu, 13 Apr 2017 10:09:23 -0700 Subject: [PATCH 4/7] Always show refresh button on compare window (annoying that it hides sometimes when it shouldn't). Move compare window prices to the new price model. --- gui/itemStats.py | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/gui/itemStats.py b/gui/itemStats.py index 41226464c..5d7fac10b 100644 --- a/gui/itemStats.py +++ b/gui/itemStats.py @@ -531,6 +531,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) @@ -587,11 +591,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) @@ -606,7 +609,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() @@ -676,9 +680,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() From 2a679efc1494b001cb061f63879f84155bcd5b55 Mon Sep 17 00:00:00 2001 From: blitzmann Date: Fri, 21 Apr 2017 01:05:16 -0400 Subject: [PATCH 5/7] Remove print message for except clause when iterating through item properties. This is dev stuff, not too worried about handling it. Was failing on getting a property that doesn't make sense for a module. --- gui/itemStats.py | 1 - 1 file changed, 1 deletion(-) diff --git a/gui/itemStats.py b/gui/itemStats.py index 5d7fac10b..6dbec6a9e 100644 --- a/gui/itemStats.py +++ b/gui/itemStats.py @@ -1384,7 +1384,6 @@ class ItemProperties(wx.Panel): except Exception as e: # 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) From c0f74cd0a3e4a56b701b168e47f7347fba3234c4 Mon Sep 17 00:00:00 2001 From: blitzmann Date: Fri, 21 Apr 2017 23:43:40 -0400 Subject: [PATCH 6/7] Fix old issue with trying to open previous fits that don't exist. --- gui/itemStats.py | 2 +- gui/mainFrame.py | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/gui/itemStats.py b/gui/itemStats.py index 6dbec6a9e..788414292 100644 --- a/gui/itemStats.py +++ b/gui/itemStats.py @@ -1381,7 +1381,7 @@ 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. continue 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) From f7349316b4219a23247fcfab2ada40a0e94ddfba Mon Sep 17 00:00:00 2001 From: blitzmann Date: Mon, 24 Apr 2017 00:34:04 -0400 Subject: [PATCH 7/7] Revert "Change to using inspect() instead of the current shitty way" This reverts commit 711537dcf4c70a73243988ad146bcc84536d82d7. Turns out inspect() was introduced in 0.8, and mac-deprecated has 0.6.4 (without an easy way to jack it up). Stuck with this ugly, but functional code for now. --- eos/gamedata.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/eos/gamedata.py b/eos/gamedata.py index d12940a8a..f6ea5183c 100644 --- a/eos/gamedata.py +++ b/eos/gamedata.py @@ -20,7 +20,6 @@ import re from sqlalchemy.orm import reconstructor -from sqlalchemy import inspect import eos.db from eqBase import EqBase @@ -444,9 +443,8 @@ class Item(EqBase): @property def price(self): - # This happens when the price record is deleted from the database. We dynamically refresh the price object - # attached to the fit if it's determined to have been deleted - if self.__price is not None and inspect(self.__price).deleted: + # 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