Esempio n. 1
0
    def optimizeFitPrice(self, event):
        fitID = self.getActiveFit()
        sFit = Fit.getInstance()
        fit = sFit.getFit(fitID)

        if fit:

            def updateFitCb(replacementsCheaper):
                del self.waitDialog
                del self.disablerAll
                rebaseMap = {
                    k.ID: v.ID
                    for k, v in replacementsCheaper.items()
                }
                self.command.Submit(
                    cmd.GuiRebaseItemsCommand(fitID=fitID,
                                              rebaseMap=rebaseMap))

            fitItems = {
                i
                for i in Fit.fitItemIter(fit, forceFitImplants=True)
                if i is not fit.ship.item
            }
            self.disablerAll = wx.WindowDisabler()
            self.waitDialog = wx.BusyInfo("Please Wait...", parent=self)
            Price.getInstance().findCheaperReplacements(fitItems,
                                                        updateFitCb,
                                                        fetchTimeout=10)
Esempio n. 2
0
    def refreshPanel(self, fit):
        if fit is not None:
            self.fit = fit
            fit_items = set(Fit.fitItemIter(fit))
            Price.getInstance().getPrices(fit_items, self.processPrices, fetchTimeout=30)
            self.labelEMStatus.SetLabel("Updating prices...")

        self.refreshPanelPrices(fit)
        self.panel.Layout()
Esempio n. 3
0
    def refreshPanel(self, fit):
        if fit is not None:
            self.fit = fit
            fit_items = set(Fit.fitItemIter(fit))
            Price.getInstance().getPrices(fit_items, self.processPrices, fetchTimeout=30)
            self.labelEMStatus.SetLabel("Updating prices...")

        self.refreshPanelPrices(fit)
        self.panel.Layout()
Esempio n. 4
0
    def refreshPanel(self, fit):
        if fit is not None:
            self.fit = fit

            fit_items = Price.fitItemsList(fit)

            sPrice = Price.getInstance()
            sPrice.getPrices(fit_items, self.processPrices)
            self.labelEMStatus.SetLabel("Updating prices...")

        self.refreshPanelPrices(fit)
        self.panel.Layout()
Esempio n. 5
0
    def refreshPanel(self, fit):
        if fit is not None:
            self.fit = fit

            fit_items = Price.fitItemsList(fit)

            sPrice = Price.getInstance()
            sPrice.getPrices(fit_items, self.processPrices)
            self.labelEMStatus.SetLabel("Updating prices...")

        self.refreshPanelPrices(fit)
        self.panel.Layout()
Esempio n. 6
0
    def delayedText(self, mod, display, colItem):
        sPrice = ServicePrice.getInstance()

        def callback(item):
            priceObj = item[0]
            colItem.SetText(formatPrice(mod, priceObj))

            display.SetItem(colItem)

        sPrice.getPrices([mod.item], callback, waitforthread=True)
Esempio n. 7
0
    def processUpdates(self):
        queue = self.queue
        while True:
            # Grab our data
            callback, requests = queue.get()

            # Grab prices, this is the time-consuming part
            if len(requests) > 0:
                Price.fetchPrices(requests)

            wx.CallAfter(callback)
            queue.task_done()

            # After we fetch prices, go through the list of waiting items and call their callbacks
            for price in requests:
                callbacks = self.wait.pop(price.typeID, None)
                if callbacks:
                    for callback in callbacks:
                        wx.CallAfter(callback)
Esempio n. 8
0
    def processUpdates(self):
        queue = self.queue
        while True:
            # Grab our data
            callback, requests = queue.get()

            # Grab prices, this is the time-consuming part
            if len(requests) > 0:
                Price.fetchPrices(requests)

            wx.CallAfter(callback)
            queue.task_done()

            # After we fetch prices, go through the list of waiting items and call their callbacks
            for price in requests:
                callbacks = self.wait.pop(price.typeID, None)
                if callbacks:
                    for callback in callbacks:
                        wx.CallAfter(callback)
Esempio n. 9
0
    def delayedText(self, mod, display, colItem):
        sPrice = ServicePrice.getInstance()

        def callback(item):
            priceObj = item[0]
            colItem.SetText(formatPrice(mod, priceObj))

            display.SetItem(colItem)

        sPrice.getPrices([mod.item], callback, waitforthread=True)
Esempio n. 10
0
    def delayedText(self, mod, display, colItem):
        sPrice = ServicePrice.getInstance()

        def callback(item):
            priceObj = item[0]
            colItem.SetText(formatPrice(mod, priceObj))

            display.SetItem(colItem)

        item = mod if isinstance(mod, Item) else mod.item
        wait = not isinstance(mod, Item)
        sPrice.getPrices([item], callback, waitforthread=wait)
Esempio n. 11
0
    def delayedText(self, mod, display, colItem):
        sPrice = ServicePrice.getInstance()

        def callback(item):
            price = item.item.price
            text = formatAmount(price.price, 3, 3, 9, currency=True) if price.price else ""
            if price.failed:
                text += " (!)"
            colItem.SetText(text)

            display.SetItem(colItem)

        sPrice.getPrices([mod.item], callback, True)
Esempio n. 12
0
    def delayedText(self, mod, display, colItem):
        sPrice = ServicePrice.getInstance()

        def callback(item):
            price = item[0]
            text = formatAmount(price.price, 3, 3, 9, currency=True) if price.price else ""
            if price.failed:
                text += " (!)"
            colItem.SetText(text)

            display.SetItem(colItem)

        sPrice.getPrices([mod.item], callback, True)
Esempio n. 13
0
    def delayedText(self, mod, display, colItem):
        sPrice = ServicePrice.getInstance()

        def callback(item):
            price = item[0]
            textItems = []
            if price.price:
                textItems.append(formatAmount(price.price, 3, 3, 9, currency=True))
            if price.status == PriceStatus.fail:
                textItems.append("(!)")
            colItem.SetText(" ".join(textItems))

            display.SetItem(colItem)

        sPrice.getPrices([mod.item], callback, True)
Esempio n. 14
0
def exportMultiBuy(fit, options, callback):
    itemAmounts = {}

    for module in fit.modules:
        if module.item:
            # Mutated items are of no use for multibuy
            if module.isMutated:
                continue
            _addItem(itemAmounts, module.item)
        if module.charge and options[PortMultiBuyOptions.LOADED_CHARGES]:
            _addItem(itemAmounts, module.charge, module.numCharges)

    for drone in fit.drones:
        _addItem(itemAmounts, drone.item, drone.amount)

    for fighter in fit.fighters:
        _addItem(itemAmounts, fighter.item, fighter.amount)

    if options[PortMultiBuyOptions.CARGO]:
        for cargo in fit.cargo:
            _addItem(itemAmounts, cargo.item, cargo.amount)

    if options[PortMultiBuyOptions.IMPLANTS]:
        for implant in fit.implants:
            _addItem(itemAmounts, implant.item)

    if options[PortMultiBuyOptions.BOOSTERS]:
        for booster in fit.boosters:
            _addItem(itemAmounts, booster.item)

    if options[PortMultiBuyOptions.OPTIMIZE_PRICES]:

        def formatCheaperExportCb(replacementsCheaper):
            updatedAmounts = {}
            for item, itemAmount in itemAmounts.items():
                _addItem(updatedAmounts, replacementsCheaper.get(item, item),
                         itemAmount)
            string = _prepareString(fit.ship.item, updatedAmounts)
            callback(string)

        priceSvc = sPrc.getInstance()
        priceSvc.findCheaperReplacements(itemAmounts, formatCheaperExportCb)
    else:
        string = _prepareString(fit.ship.item, itemAmounts)
        if callback:
            callback(string)
        else:
            return string
Esempio n. 15
0
    def refreshPanel(self, fit):
        if fit is not None:
            self.fit = fit

            typeIDs = Price.fitItemsList(fit)

            sMkt = Market.getInstance()
            sMkt.getPrices(typeIDs, self.processPrices)
            self.labelEMStatus.SetLabel("Updating prices...")
        else:
            self.labelEMStatus.SetLabel("")
            self.labelPriceShip.SetLabel("0.0 ISK")
            self.labelPriceFittings.SetLabel("0.0 ISK")
            self.labelPriceTotal.SetLabel("0.0 ISK")
            self._cachedFittings = self._cachedShip = self._cachedTotal = 0
            self.panel.Layout()
Esempio n. 16
0
def exportMultiBuy(fit, options, callback):
    itemAmounts = {}

    for module in fit.modules:
        if module.item:
            # Mutated items are of no use for multibuy
            if module.isMutated:
                continue
            _addItem(itemAmounts, module.item)
        if module.charge and options[PortMultiBuyOptions.LOADED_CHARGES]:
            _addItem(itemAmounts, module.charge, module.numCharges)

    for drone in fit.drones:
        _addItem(itemAmounts, drone.item, drone.amount)

    for fighter in fit.fighters:
        _addItem(itemAmounts, fighter.item, fighter.amountActive)

    if options[PortMultiBuyOptions.CARGO]:
        for cargo in fit.cargo:
            _addItem(itemAmounts, cargo.item, cargo.amount)

    if options[PortMultiBuyOptions.IMPLANTS]:
        for implant in fit.implants:
            _addItem(itemAmounts, implant.item)

        for booster in fit.boosters:
            _addItem(itemAmounts, booster.item)

    if options[PortMultiBuyOptions.OPTIMIZE_PRICES]:

        def formatCheaperExportCb(replacementsCheaper):
            updatedAmounts = {}
            for item, itemAmount in itemAmounts.items():
                _addItem(updatedAmounts, replacementsCheaper.get(item, item), itemAmount)
            string = _prepareString(fit.ship.item, updatedAmounts)
            callback(string)

        priceSvc = sPrc.getInstance()
        priceSvc.findCheaperReplacements(itemAmounts, formatCheaperExportCb)
    else:
        string = _prepareString(fit.ship.item, itemAmounts)
        if callback:
            callback(string)
        else:
            return string
Esempio n. 17
0
    @staticmethod
    def fetchPrices(priceMap, fetchTimeout, system=None):
        params = {"type_ids": ','.join(str(typeID) for typeID in priceMap)}
        if system is not None:
            params["system_id"] = system
        baseurl = "https://eve-marketdata.com/api/item_prices.xml"
        network = Network.getInstance()
        data = network.request(baseurl, network.PRICES, params=params, timeout=fetchTimeout)
        xml = minidom.parseString(data.text)
        types = xml.getElementsByTagName("eve").item(0).getElementsByTagName("price")

        # Cycle through all types we've got from request
        for type_ in types:
            # Get data out of each typeID details tree
            typeID = int(type_.getAttribute("id"))

            try:
                price = float(type_.firstChild.data)
            except (TypeError, ValueError):
                pyfalog.warning("Failed to get price for: {0}", type_)
                continue

            # eve-marketdata returns 0 if price data doesn't even exist for the item
            if price == 0:
                continue
            priceMap[typeID].update(PriceStatus.fetchSuccess, price)
            del priceMap[typeID]


Price.register(EveMarketData)
Esempio n. 18
0
 def activate(self, fullContext, selection, i):
     sPrc = Price.getInstance()
     sPrc.clearPriceCache()
     wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.mainFrame.getActiveFit()))
Esempio n. 19
0
                           type=network.PRICES,
                           params=params,
                           timeout=fetchTimeout)
        xml = minidom.parseString(data.text)
        types = xml.getElementsByTagName('marketstat').item(
            0).getElementsByTagName('type')
        # Cycle through all types we've got from request
        for type_ in types:
            # Get data out of each typeID details tree
            typeID = int(type_.getAttribute('id'))
            sell = type_.getElementsByTagName('sell').item(0)
            # If price data wasn't there, skip the item
            try:
                percprice = float(
                    sell.getElementsByTagName('percentile').item(
                        0).firstChild.data)
            except (TypeError, ValueError):
                pyfalog.warning('Failed to get price for: {0}', type_)
                continue

            # Price is 0 if evemarketer has info on this item, but it is not available
            # for current scope limit. If we provided scope limit - make sure to skip
            # such items to check globally, and do not skip if requested globally
            if percprice == 0 and system is not None:
                continue
            priceMap[typeID].update(PriceStatus.fetchSuccess, percprice)
            del priceMap[typeID]


Price.register(EveMarketer)
Esempio n. 20
0
        baseurl = 'https://evepraisal.com/appraisal/structured.json'
        network = Network.getInstance()
        resp = network.post(baseurl,
                            network.PRICES,
                            jsonData=jsonData,
                            timeout=fetchTimeout)
        data = resp.json()
        try:
            itemsData = data['appraisal']['items']
        except (KeyError, TypeError):
            return
        # Cycle through all types we've got from request
        for itemData in itemsData:
            try:
                typeID = int(itemData['typeID'])
                price = itemData['prices']['sell']['min']
                orderCount = itemData['prices']['sell']['order_count']
            except (KeyError, TypeError):
                continue
            # evepraisal returns 0 if price data doesn't even exist for the item
            if price == 0:
                continue
            # evepraisal seems to provide price for some items despite having no orders up
            if orderCount < 1:
                continue
            priceMap[typeID].update(PriceStatus.fetchSuccess, price)
            del priceMap[typeID]


Price.register(EvePraisal)
Esempio n. 21
0
        if system is not None:
            params["usesystem"] = system
        baseurl = "https://api.evemarketer.com/ec/marketstat"
        network = Network.getInstance()
        data = network.request(baseurl, network.PRICES, params=params, timeout=fetchTimeout)
        xml = minidom.parseString(data.text)
        types = xml.getElementsByTagName("marketstat").item(0).getElementsByTagName("type")
        # Cycle through all types we've got from request
        for type_ in types:
            # Get data out of each typeID details tree
            typeID = int(type_.getAttribute("id"))
            sell = type_.getElementsByTagName("sell").item(0)
            # If price data wasn't there, set price to zero
            try:
                percprice = float(sell.getElementsByTagName("percentile").item(0).firstChild.data)
            except (TypeError, ValueError):
                pyfalog.warning("Failed to get price for: {0}", type_)
                continue

            # Price is 0 if evemarketer has info on this item, but it is not available
            # for current scope limit. If we provided scope limit - make sure to skip
            # such items to check globally, and do not skip if requested globally
            if percprice == 0 and system is not None:
                continue

            priceMap[typeID].update(PriceStatus.fetchSuccess, percprice)
            del priceMap[typeID]


Price.register(EveMarketer)
Esempio n. 22
0
    def __init__(self, priceMap, system, fetchTimeout):
        # Try selected system first
        self.fetchPrices(priceMap,
                         max(2 * fetchTimeout / 3, 2),
                         system,
                         serenity=False)
        # If price was not available - try globally
        if priceMap:
            self.fetchPrices(priceMap,
                             max(fetchTimeout / 3, 2),
                             serenity=False)


class CEveMarketCn(CEveMarketBase):
    name = 'www.ceve-market.org (Serenity)'  #let me at last

    def __init__(self, priceMap, system, fetchTimeout):
        # Try selected system first
        self.fetchPrices(priceMap,
                         max(2 * fetchTimeout / 3, 2),
                         system,
                         serenity=True)
        # If price was not available - try globally
        if priceMap:
            self.fetchPrices(priceMap, max(fetchTimeout / 3, 2), serenity=True)


Price.register(CEveMarketCn)
Price.register(CEveMarketTq)
Esempio n. 23
0
 def activate(self, fullContext, selection, i):
     sPrc = Price.getInstance()
     sPrc.clearPriceCache()
     wx.PostEvent(self.mainFrame,
                  GE.FitChanged(fitID=self.mainFrame.getActiveFit()))
Esempio n. 24
0
    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)

        self.paramList = AutoListCtrl(self, wx.ID_ANY,
                                      style=wx.LC_REPORT | wx.LC_SINGLE_SEL | wx.LC_VRULES | wx.NO_BORDER)
        mainSizer.Add(self.paramList, 1, wx.ALL | wx.EXPAND, 0)
        self.SetSizer(mainSizer)

        self.toggleView = 1
        self.stuff = stuff
        self.currentSort = None
        self.sortReverse = False
        self.item = item
        self.items = sorted(items,
                            key=lambda x: x.attributes['metaLevel'].value if 'metaLevel' in x.attributes else 0)
        self.attrs = {}

        # get a dict of attrName: attrInfo of all unique attributes across all items
        for item in self.items:
            for attr in list(item.attributes.keys()):
                if item.attributes[attr].info.displayName:
                    self.attrs[attr] = item.attributes[attr].info

        # Process attributes for items and find ones that differ
        for attr in list(self.attrs.keys()):
            value = None

            for item in self.items:
                # we can automatically break here if this item doesn't have the attribute,
                # as that means at least one item did
                if attr not in item.attributes:
                    break

                # this is the first attribute for the item set, set the initial value
                if value is None:
                    value = item.attributes[attr].value
                    continue

                if attr not in item.attributes or item.attributes[attr].value != value:
                    break
            else:
                # attribute values were all the same, delete
                del self.attrs[attr]

        self.m_staticline = wx.StaticLine(self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize,
                                          wx.LI_HORIZONTAL)
        mainSizer.Add(self.m_staticline, 0, wx.EXPAND)
        bSizer = wx.BoxSizer(wx.HORIZONTAL)

        self.totalAttrsLabel = wx.StaticText(self, wx.ID_ANY, " ", wx.DefaultPosition, wx.DefaultSize, 0)
        bSizer.Add(self.totalAttrsLabel, 0, wx.ALIGN_CENTER_VERTICAL | wx.RIGHT)

        self.toggleViewBtn = wx.ToggleButton(self, wx.ID_ANY, "Toggle view mode", wx.DefaultPosition,
                                             wx.DefaultSize, 0)
        bSizer.Add(self.toggleViewBtn, 0, wx.ALIGN_CENTER_VERTICAL)

        self.refreshBtn = wx.Button(self, wx.ID_ANY, "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)

        self.PopulateList()

        self.toggleViewBtn.Bind(wx.EVT_TOGGLEBUTTON, self.ToggleViewMode)
        self.Bind(wx.EVT_LIST_COL_CLICK, self.SortCompareCols)
Esempio n. 25
0
            "price")

        # Cycle through all types we've got from request
        for type_ in types:
            # Get data out of each typeID details tree
            typeID = int(type_.getAttribute("id"))

            try:
                price = float(type_.firstChild.data)
            except (TypeError, ValueError):
                pyfalog.warning("Failed to get price for: {0}", type_)

            # Fill price data
            priceobj = priceMap[typeID]

            # eve-marketdata returns 0 if price data doesn't even exist for the item. In this case, don't reset the
            # cached price, and set the price timeout to TIMEOUT (every 15 minutes currently). Se GH issue #1334
            if price != 0:
                priceobj.price = price
                priceobj.time = time.time() + VALIDITY
            else:
                priceobj.time = time.time() + TIMEOUT

            priceobj.failed = None

            # delete price from working dict
            del priceMap[typeID]


Price.register(EveMarketData)
Esempio n. 26
0
        network = Network.getInstance()
        data = network.request(baseurl, network.PRICES, params=data)
        xml = minidom.parseString(data.text)
        types = xml.getElementsByTagName("marketstat").item(
            0).getElementsByTagName("type")
        # Cycle through all types we've got from request
        for type_ in types:
            # Get data out of each typeID details tree
            typeID = int(type_.getAttribute("id"))
            sell = type_.getElementsByTagName("sell").item(0)
            # If price data wasn't there, set price to zero
            try:
                percprice = float(
                    sell.getElementsByTagName("percentile").item(
                        0).firstChild.data)
            except (TypeError, ValueError):
                pyfalog.warning("Failed to get price for: {0}", type_)
                percprice = 0

            # Fill price data
            priceobj = priceMap[typeID]
            priceobj.price = percprice
            priceobj.time = time.time() + VALIDITY
            priceobj.failed = None

            # delete price from working dict
            del priceMap[typeID]


Price.register(EveCentral)
Esempio n. 27
0
        for typeID in types:  # Add all typeID arguments
            data.append(("typeid", typeID))

        network = Network.getInstance()
        data = network.request(baseurl, network.PRICES, data)
        xml = minidom.parse(data)
        types = xml.getElementsByTagName("marketstat").item(0).getElementsByTagName("type")
        # Cycle through all types we've got from request
        for type_ in types:
            # Get data out of each typeID details tree
            typeID = int(type_.getAttribute("id"))
            sell = type_.getElementsByTagName("sell").item(0)
            # If price data wasn't there, set price to zero
            try:
                percprice = float(sell.getElementsByTagName("percentile").item(0).firstChild.data)
            except (TypeError, ValueError):
                pyfalog.warning("Failed to get price for: {0}", type_)
                percprice = 0

            # Fill price data
            priceobj = priceMap[typeID]
            priceobj.price = percprice
            priceobj.time = time.time() + VALIDITY
            priceobj.failed = None

            # delete price from working dict
            del priceMap[typeID]


Price.register(EveCentral)
Esempio n. 28
0
    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)

        self.paramList = AutoListCtrl(self,
                                      wx.ID_ANY,
                                      style=wx.LC_REPORT | wx.LC_SINGLE_SEL
                                      | wx.LC_VRULES | wx.NO_BORDER)
        mainSizer.Add(self.paramList, 1, wx.ALL | wx.EXPAND, 0)
        self.SetSizer(mainSizer)

        self.toggleView = 1
        self.stuff = stuff
        self.currentSort = None
        self.sortReverse = False
        self.item = item
        self.items = sorted(items,
                            key=lambda x: x.attributes['metaLevel'].value
                            if 'metaLevel' in x.attributes else 0)
        self.attrs = {}

        # get a dict of attrName: attrInfo of all unique attributes across all items
        for item in self.items:
            for attr in list(item.attributes.keys()):
                if item.attributes[attr].info.displayName:
                    self.attrs[attr] = item.attributes[attr].info

        # Process attributes for items and find ones that differ
        for attr in list(self.attrs.keys()):
            value = None

            for item in self.items:
                # we can automatically break here if this item doesn't have the attribute,
                # as that means at least one item did
                if attr not in item.attributes:
                    break

                # this is the first attribute for the item set, set the initial value
                if value is None:
                    value = item.attributes[attr].value
                    continue

                if attr not in item.attributes or item.attributes[
                        attr].value != value:
                    break
            else:
                # attribute values were all the same, delete
                del self.attrs[attr]

        self.m_staticline = wx.StaticLine(self, wx.ID_ANY, wx.DefaultPosition,
                                          wx.DefaultSize, wx.LI_HORIZONTAL)
        mainSizer.Add(self.m_staticline, 0, wx.EXPAND)
        bSizer = wx.BoxSizer(wx.HORIZONTAL)

        self.totalAttrsLabel = wx.StaticText(self, wx.ID_ANY, " ",
                                             wx.DefaultPosition,
                                             wx.DefaultSize, 0)
        bSizer.Add(self.totalAttrsLabel, 0,
                   wx.ALIGN_CENTER_VERTICAL | wx.RIGHT)

        self.toggleViewBtn = wx.ToggleButton(self, wx.ID_ANY,
                                             "Toggle view mode",
                                             wx.DefaultPosition,
                                             wx.DefaultSize, 0)
        bSizer.Add(self.toggleViewBtn, 0, wx.ALIGN_CENTER_VERTICAL)

        self.refreshBtn = wx.Button(self, wx.ID_ANY, "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)

        self.PopulateList()

        self.toggleViewBtn.Bind(wx.EVT_TOGGLEBUTTON, self.ToggleViewMode)
        self.Bind(wx.EVT_LIST_COL_CLICK, self.SortCompareCols)
Esempio n. 29
0
        # If price was not available - try globally
        if priceMap:
            self.fetchPrices(priceMap, max(fetchTimeout / 3, 2))

    @staticmethod
    def fetchPrices(priceMap, fetchTimeout, system=None):
        params = {'types': ','.join(str(typeID) for typeID in priceMap)}
        for k, v in locations.get(system, {}).items():
            params[k] = v
        baseurl = 'https://market.fuzzwork.co.uk/aggregates/'
        network = Network.getInstance()
        resp = network.get(url=baseurl, type=network.PRICES, params=params, timeout=fetchTimeout)
        data = resp.json()
        # Cycle through all types we've got from request
        for typeID, typeData in data.items():
            try:
                typeID = int(typeID)
                price = float(typeData['sell']['percentile'])
            except (KeyError, TypeError):
                continue
            # Fuzzworks returns 0 when there's no data for item
            if price == 0:
                continue
            if typeID not in priceMap:
                continue
            priceMap[typeID].update(PriceStatus.fetchSuccess, price)
            del priceMap[typeID]


Price.register(FuzzworkMarket)