| 38 | |
| 39 | |
| 40 | class Price: |
| 41 | instance = None |
| 42 | |
| 43 | systemsList = { |
| 44 | "Jita": 30000142, |
| 45 | "Amarr": 30002187, |
| 46 | "Dodixie": 30002659, |
| 47 | "Rens": 30002510, |
| 48 | "Hek": 30002053 |
| 49 | } |
| 50 | |
| 51 | sources = {} |
| 52 | |
| 53 | def __init__(self): |
| 54 | # Start price fetcher |
| 55 | self.priceWorkerThread = PriceWorkerThread() |
| 56 | self.priceWorkerThread.daemon = True |
| 57 | self.priceWorkerThread.start() |
| 58 | |
| 59 | @classmethod |
| 60 | def register(cls, source): |
| 61 | cls.sources[source.name] = source |
| 62 | |
| 63 | @classmethod |
| 64 | def getInstance(cls): |
| 65 | if cls.instance is None: |
| 66 | cls.instance = Price() |
| 67 | return cls.instance |
| 68 | |
| 69 | @classmethod |
| 70 | def fetchPrices(cls, prices, fetchTimeout, validityOverride): |
| 71 | """Fetch all prices passed to this method""" |
| 72 | |
| 73 | # Dictionary for our price objects |
| 74 | priceMap = {} |
| 75 | # Check all provided price objects, and add those we want to update to |
| 76 | # dictionary |
| 77 | for price in prices: |
| 78 | if not price.isValid(validityOverride): |
| 79 | priceMap[price.typeID] = price |
| 80 | |
| 81 | if not priceMap: |
| 82 | return |
| 83 | |
| 84 | # Compose list of items we're going to request |
| 85 | for typeID in tuple(priceMap): |
| 86 | # Get item object |
| 87 | item = db.getItem(typeID) |
| 88 | # We're not going to request items only with market group, as our current market |
| 89 | # sources do not provide any data for items not on the market |
| 90 | if item is None: |
| 91 | continue |
| 92 | if not item.marketGroupID: |
| 93 | priceMap[typeID].update(PriceStatus.notSupported) |
| 94 | del priceMap[typeID] |
| 95 | continue |
| 96 | |
| 97 | if not priceMap: |