Make it run again

This commit is contained in:
Ebag333
2016-12-02 03:13:54 -08:00
parent bb96b0af1a
commit d963327ed4
94 changed files with 631 additions and 583 deletions

View File

@@ -17,12 +17,13 @@
# along with pyfa. If not, see <http://www.gnu.org/licenses/>.
#===============================================================================
import service
import eos.db
import eos.types
import time
from xml.dom import minidom
import eos
from service.network import Network, TimeoutError
VALIDITY = 24*60*60 # Price validity period, 24 hours
REREQUEST = 4*60*60 # Re-request delay for failed fetches, 4 hours
TIMEOUT = 15*60 # Network timeout delay for connection issues, 15 minutes
@@ -71,15 +72,15 @@ class Price():
# Attempt to send request and process it
try:
network = service.Network.getInstance()
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:
for type_ in types:
# Get data out of each typeID details tree
typeID = int(type.getAttribute("id"))
sell = type.getElementsByTagName("sell").item(0)
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)
@@ -96,7 +97,7 @@ class Price():
del priceMap[typeID]
# If getting or processing data returned any errors
except service.network.TimeoutError, e:
except TimeoutError:
# Timeout error deserves special treatment
for typeID in priceMap.keys():
priceobj = priceMap[typeID]