From 874cf4ef0a30bd2a6d58fc1831bc918ffb5a373e Mon Sep 17 00:00:00 2001 From: blitzmann Date: Fri, 3 Jul 2015 02:37:52 -0400 Subject: [PATCH] Use old price information if update fails. Add "(!)" to show that price is out of date --- eos/saveddata/price.py | 1 + gui/builtinStatsViews/priceViewFull.py | 5 +---- gui/builtinViewColumns/price.py | 12 ++++++++---- service/market.py | 4 ---- service/price.py | 6 ++---- 5 files changed, 12 insertions(+), 16 deletions(-) diff --git a/eos/saveddata/price.py b/eos/saveddata/price.py index 4c7de879c..ea9b0ac92 100644 --- a/eos/saveddata/price.py +++ b/eos/saveddata/price.py @@ -26,6 +26,7 @@ class Price(object): def __init__(self, typeID): self.typeID = typeID self.time = 0 + self.price = 0 self.failed = None self.__item = None diff --git a/gui/builtinStatsViews/priceViewFull.py b/gui/builtinStatsViews/priceViewFull.py index eba4c134b..f1d3fbd1d 100644 --- a/gui/builtinStatsViews/priceViewFull.py +++ b/gui/builtinStatsViews/priceViewFull.py @@ -103,10 +103,7 @@ class PriceViewFull(StatsView): shipPrice = prices[0].price modPrice = sum(map(lambda p: p.price or 0, prices[1:])) - if shipPrice is not None: - self.labelEMStatus.SetLabel("") - else: - shipPrice = 0 + self.labelEMStatus.SetLabel("") if self._cachedShip != shipPrice: self.labelPriceShip.SetLabel("%s ISK" % formatAmount(shipPrice, 3, 3, 9, currency=True)) diff --git a/gui/builtinViewColumns/price.py b/gui/builtinViewColumns/price.py index df88d0893..17c7ade3c 100644 --- a/gui/builtinViewColumns/price.py +++ b/gui/builtinViewColumns/price.py @@ -39,7 +39,7 @@ class Price(ViewColumn): sMkt = service.Market.getInstance() price = sMkt.getPriceNow(stuff.item.ID) - if not price or not price.price: + if not price or not price.price or not price.isValid: return False price = price.price # Set new price variable with what we need @@ -52,9 +52,13 @@ class Price(ViewColumn): def delayedText(self, mod, display, colItem): sMkt = service.Market.getInstance() def callback(item): - price = sMkt.getPriceNow(item.ID).price - colItem.SetText(formatAmount(price, 3, 3, 9, currency=True) if price else "") - display.SetItem(colItem) + price = sMkt.getPriceNow(item.ID) + text = formatAmount(price.price, 3, 3, 9, currency=True) if price.price else "" + if price.failed: text += " (!)" + colItem.SetText(text) + + display.SetItem(colItem) + sMkt.waitForPrice(mod.item, callback) diff --git a/service/market.py b/service/market.py index 951f31456..ef4cf387a 100644 --- a/service/market.py +++ b/service/market.py @@ -706,10 +706,6 @@ class Market(): self.priceCache[typeID] = price - if not price.isValid: - # if the price has expired - price.price = None - return price def getPricesNow(self, typeIDs): diff --git a/service/price.py b/service/price.py index aefd1b14f..78e3e289b 100644 --- a/service/price.py +++ b/service/price.py @@ -71,7 +71,6 @@ class Price(): # Attempt to send request and process it try: - len(priceMap) network = service.Network.getInstance() data = network.request(baseurl, network.PRICES, data) xml = minidom.parse(data) @@ -102,7 +101,7 @@ class Price(): for typeID in priceMap.keys(): priceobj = priceMap[typeID] priceobj.time = time.time() + TIMEOUT - priceobj.failed = None + priceobj.failed = True del priceMap[typeID] except: # all other errors will pass and continue onward to the REREQUEST delay @@ -111,6 +110,5 @@ class Price(): # if we get to this point, then we've got an error. Set to REREQUEST delay for typeID in priceMap.keys(): priceobj = priceMap[typeID] - priceobj.price = 0 priceobj.time = time.time() + REREQUEST - priceobj.failed = None + priceobj.failed = True