コード例 #1
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)
コード例 #2
0
ファイル: evemarketer.py プロジェクト: m-sasha/PyfaAT
        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)
コード例 #3
0
ファイル: evemarketer.py プロジェクト: zjx1994/Pyfa
                           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)
コード例 #4
0
ファイル: evemarketdata.py プロジェクト: blitzmann/Pyfa
    @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)
コード例 #5
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)
コード例 #6
0
ファイル: evecentral.py プロジェクト: copyliu/Pyfa
        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)
コード例 #7
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)
コード例 #8
0
ファイル: evemarketer.py プロジェクト: blitzmann/Pyfa
        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)
コード例 #9
0
ファイル: fuzzwork.py プロジェクト: zjx1994/Pyfa
        # 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)