Merge branch 'development' into MorePreferences

This commit is contained in:
blitzman
2017-03-26 13:52:59 -04:00
58 changed files with 1032 additions and 367 deletions

View File

@@ -194,11 +194,13 @@ class Character(object):
@staticmethod
def backupSkills(path, saveFmt, activeFit, callback):
thread = SkillBackupThread(path, saveFmt, activeFit, callback)
pyfalog.debug("Starting backup skills thread.")
thread.start()
@staticmethod
def importCharacter(path, callback):
thread = CharacterImportThread(path, callback)
pyfalog.debug("Starting import character thread.")
thread.start()
@staticmethod

View File

@@ -19,6 +19,7 @@
import copy
from logbook import Logger
from time import time
import eos.db
from eos.saveddata.booster import Booster as es_Booster
@@ -81,12 +82,14 @@ class Fit(object):
@staticmethod
def getAllFits():
pyfalog.debug("Fetching all fits")
fits = eos.db.getFitList()
return fits
@staticmethod
def getFitsWithShip(shipID):
""" Lists fits of shipID, used with shipBrowser """
pyfalog.debug("Fetching all fits for ship ID: {0}", shipID)
fits = eos.db.getFitsWithShip(shipID)
names = []
for fit in fits:
@@ -97,6 +100,7 @@ class Fit(object):
@staticmethod
def getBoosterFits():
""" Lists fits flagged as booster """
pyfalog.debug("Fetching all fits flagged as a booster.")
fits = eos.db.getBoosterFits()
names = []
for fit in fits:
@@ -106,10 +110,12 @@ class Fit(object):
@staticmethod
def countAllFits():
pyfalog.debug("Getting count of all fits.")
return eos.db.countAllFits()
@staticmethod
def countFitsWithShip(stuff):
pyfalog.debug("Getting count of all fits for: {0}", stuff)
count = eos.db.countFitsWithShip(stuff)
return count
@@ -119,6 +125,7 @@ class Fit(object):
return fit.modules[pos]
def newFit(self, shipID, name=None):
pyfalog.debug("Creating new fit for ID: {0}", shipID)
try:
ship = es_Ship(eos.db.getItem(shipID))
except ValueError:
@@ -135,18 +142,21 @@ class Fit(object):
@staticmethod
def toggleBoostFit(fitID):
pyfalog.debug("Toggling as booster for fit ID: {0}", fitID)
fit = eos.db.getFit(fitID)
fit.booster = not fit.booster
eos.db.commit()
@staticmethod
def renameFit(fitID, newName):
pyfalog.debug("Renaming fit ({0}) to: {1}", fitID, newName)
fit = eos.db.getFit(fitID)
fit.name = newName
eos.db.commit()
@staticmethod
def deleteFit(fitID):
pyfalog.debug("Deleting fit for fit ID: {0}", fitID)
fit = eos.db.getFit(fitID)
eos.db.remove(fit)
@@ -159,6 +169,7 @@ class Fit(object):
@staticmethod
def copyFit(fitID):
pyfalog.debug("Creating copy of fit ID: {0}", fitID)
fit = eos.db.getFit(fitID)
newFit = copy.deepcopy(fit)
eos.db.save(newFit)
@@ -166,6 +177,7 @@ class Fit(object):
@staticmethod
def clearFit(fitID):
pyfalog.debug("Clearing fit for fit ID: {0}", fitID)
if fitID is None:
return None
@@ -174,6 +186,7 @@ class Fit(object):
return fit
def toggleFactorReload(self, fitID):
pyfalog.debug("Toggling factor reload for fit ID: {0}", fitID)
if fitID is None:
return None
@@ -183,6 +196,7 @@ class Fit(object):
self.recalc(fit)
def switchFit(self, fitID):
pyfalog.debug("Switching fit to fit ID: {0}", fitID)
if fitID is None:
return None
@@ -206,6 +220,7 @@ class Fit(object):
Projected is a recursion flag that is set to reduce recursions into projected fits
Basic is a flag to simply return the fit without any other processing
"""
pyfalog.debug("Getting fit for fit ID: {0}", fitID)
if fitID is None:
return None
fit = eos.db.getFit(fitID)
@@ -231,6 +246,7 @@ class Fit(object):
@staticmethod
def searchFits(name):
pyfalog.debug("Searching for fit: {0}", name)
results = eos.db.searchFits(name)
fits = []
for fit in results:
@@ -240,6 +256,7 @@ class Fit(object):
return fits
def addImplant(self, fitID, itemID, recalc=True):
pyfalog.debug("Adding implant to fit ({0}) for item ID: {1}", fitID, itemID)
if fitID is None:
return False
@@ -248,6 +265,7 @@ class Fit(object):
try:
implant = es_Implant(item)
except ValueError:
pyfalog.warning("Invalid item: {0}", itemID)
return False
fit.implants.append(implant)
@@ -256,6 +274,7 @@ class Fit(object):
return True
def removeImplant(self, fitID, position):
pyfalog.debug("Removing implant from position ({0}) for fit ID: {1}", position, fitID)
if fitID is None:
return False
@@ -266,6 +285,7 @@ class Fit(object):
return True
def addBooster(self, fitID, itemID):
pyfalog.debug("Adding booster ({0}) to fit ID: {1}", itemID, fitID)
if fitID is None:
return False
@@ -274,6 +294,7 @@ class Fit(object):
try:
booster = es_Booster(item)
except ValueError:
pyfalog.warning("Invalid item: {0}", itemID)
return False
fit.boosters.append(booster)
@@ -281,6 +302,7 @@ class Fit(object):
return True
def removeBooster(self, fitID, position):
pyfalog.debug("Removing booster from position ({0}) for fit ID: {1}", position, fitID)
if fitID is None:
return False
@@ -291,6 +313,7 @@ class Fit(object):
return True
def project(self, fitID, thing):
pyfalog.debug("Projecting fit ({0}) onto: {1}", fitID, thing)
if fitID is None:
return
@@ -340,6 +363,7 @@ class Fit(object):
return True
def addCommandFit(self, fitID, thing):
pyfalog.debug("Projecting command fit ({0}) onto: {1}", fitID, thing)
if fitID is None:
return
@@ -359,6 +383,7 @@ class Fit(object):
return True
def toggleProjected(self, fitID, thing, click):
pyfalog.debug("Toggling projected on fit ({0}) for: {1}", fitID, thing)
fit = eos.db.getFit(fitID)
if isinstance(thing, es_Drone):
if thing.amountActive == 0 and thing.canBeApplied(fit):
@@ -380,6 +405,7 @@ class Fit(object):
self.recalc(fit)
def toggleCommandFit(self, fitID, thing):
pyfalog.debug("Toggle command fit ({0}) for: {1}", fitID, thing)
fit = eos.db.getFit(fitID)
commandInfo = thing.getCommandInfo(fitID)
if commandInfo:
@@ -390,6 +416,7 @@ class Fit(object):
def changeAmount(self, fitID, projected_fit, amount):
"""Change amount of projected fits"""
pyfalog.debug("Changing fit ({0}) for projected fit ({1}) to new amount: {2}", fitID, projected_fit.getProjectionInfo(fitID), amount)
fit = eos.db.getFit(fitID)
amount = min(20, max(1, amount)) # 1 <= a <= 20
projectionInfo = projected_fit.getProjectionInfo(fitID)
@@ -400,6 +427,7 @@ class Fit(object):
self.recalc(fit)
def changeActiveFighters(self, fitID, fighter, amount):
pyfalog.debug("Changing active fighters ({0}) for fit ({1}) to amount: {2}", fighter.itemID, amount)
fit = eos.db.getFit(fitID)
fighter.amountActive = amount
@@ -407,6 +435,7 @@ class Fit(object):
self.recalc(fit)
def removeProjected(self, fitID, thing):
pyfalog.debug("Removing projection on fit ({0}) from: {1}", fitID, thing)
fit = eos.db.getFit(fitID)
if isinstance(thing, es_Drone):
fit.projectedDrones.remove(thing)
@@ -422,6 +451,7 @@ class Fit(object):
self.recalc(fit)
def removeCommand(self, fitID, thing):
pyfalog.debug("Removing command projection from fit ({0}) for: {1}", fitID, thing)
fit = eos.db.getFit(fitID)
del fit.__commandFits[thing.ID]
@@ -429,11 +459,13 @@ class Fit(object):
self.recalc(fit)
def appendModule(self, fitID, itemID):
pyfalog.debug("Appending module for fit ({0}) using item: {1}", fitID, itemID)
fit = eos.db.getFit(fitID)
item = eos.db.getItem(itemID, eager=("attributes", "group.category"))
try:
m = es_Module(item)
except ValueError:
pyfalog.warning("Invalid item: {0}", itemID)
return False
if m.item.category.name == "Subsystem":
@@ -459,6 +491,7 @@ class Fit(object):
return None
def removeModule(self, fitID, position):
pyfalog.debug("Removing module from position ({0}) for fit ID: {1}", position, fitID)
fit = eos.db.getFit(fitID)
if fit.modules[position].isEmpty:
return None
@@ -472,6 +505,7 @@ class Fit(object):
return numSlots != len(fit.modules)
def changeModule(self, fitID, position, newItemID):
pyfalog.debug("Changing position of module from position ({0}) for fit ID: {1}", position, fitID)
fit = eos.db.getFit(fitID)
# Dummy it out in case the next bit fails
@@ -481,6 +515,7 @@ class Fit(object):
try:
m = es_Module(item)
except ValueError:
pyfalog.warning("Invalid item: {0}", newItemID)
return False
if m.fits(fit):
@@ -509,6 +544,7 @@ class Fit(object):
sanity checks as opposed to the GUI View. This is different than how the
normal .swapModules() does things, which is mostly a blind swap.
"""
pyfalog.debug("Moving cargo item to module for fit ID: {1}", fitID)
fit = eos.db.getFit(fitID)
module = fit.modules[moduleIdx]
@@ -521,6 +557,7 @@ class Fit(object):
if cargoP.isValidState(State.ACTIVE):
cargoP.state = State.ACTIVE
except:
pyfalog.warning("Invalid item: {0}", cargo.item)
return
if cargoP.slot != module.slot: # can't swap modules to different racks
@@ -555,6 +592,7 @@ class Fit(object):
@staticmethod
def swapModules(fitID, src, dst):
pyfalog.debug("Swapping modules from source ({0}) to destination ({1}) for fit ID: {1}", src, dst, fitID)
fit = eos.db.getFit(fitID)
# Gather modules
srcMod = fit.modules[src]
@@ -574,6 +612,7 @@ class Fit(object):
This will overwrite dst! Checking for empty module must be
done at a higher level
"""
pyfalog.debug("Cloning modules from source ({0}) to destination ({1}) for fit ID: {1}", src, dst, fitID)
fit = eos.db.getFit(fitID)
# Gather modules
srcMod = fit.modules[src]
@@ -594,6 +633,7 @@ class Fit(object):
Adds cargo via typeID of item. If replace = True, we replace amount with
given parameter, otherwise we increment
"""
pyfalog.debug("Adding cargo ({0}) fit ID: {1}", itemID, fitID)
if fitID is None:
return False
@@ -626,6 +666,7 @@ class Fit(object):
return True
def removeCargo(self, fitID, position):
pyfalog.debug("Removing cargo from position ({0}) fit ID: {1}", position, fitID)
if fitID is None:
return False
@@ -636,6 +677,7 @@ class Fit(object):
return True
def addFighter(self, fitID, itemID):
pyfalog.debug("Adding fighters ({0}) to fit ID: {1}", itemID, fitID)
if fitID is None:
return False
@@ -682,6 +724,7 @@ class Fit(object):
return False
def removeFighter(self, fitID, i):
pyfalog.debug("Removing fighters from fit ID: {0}", fitID)
fit = eos.db.getFit(fitID)
f = fit.fighters[i]
fit.fighters.remove(f)
@@ -691,6 +734,7 @@ class Fit(object):
return True
def addDrone(self, fitID, itemID, numDronesToAdd=1):
pyfalog.debug("Adding {0} drones ({1}) to fit ID: {2}", numDronesToAdd, itemID, fitID)
if fitID is None:
return False
@@ -717,6 +761,7 @@ class Fit(object):
return False
def mergeDrones(self, fitID, d1, d2, projected=False):
pyfalog.debug("Merging drones on fit ID: {0}", fitID)
if fitID is None:
return False
@@ -743,6 +788,7 @@ class Fit(object):
@staticmethod
def splitDrones(fit, d, amount, l):
pyfalog.debug("Splitting drones for fit ID: {0}", fit)
total = d.amount
active = d.amountActive > 0
d.amount = amount
@@ -755,6 +801,7 @@ class Fit(object):
eos.db.commit()
def splitProjectedDroneStack(self, fitID, d, amount):
pyfalog.debug("Splitting projected drone stack for fit ID: {0}", fitID)
if fitID is None:
return False
@@ -762,6 +809,7 @@ class Fit(object):
self.splitDrones(fit, d, amount, fit.projectedDrones)
def splitDroneStack(self, fitID, d, amount):
pyfalog.debug("Splitting drone stack for fit ID: {0}", fitID)
if fitID is None:
return False
@@ -769,6 +817,7 @@ class Fit(object):
self.splitDrones(fit, d, amount, fit.drones)
def removeDrone(self, fitID, i, numDronesToRemove=1):
pyfalog.debug("Removing {0} drones for fit ID: {1}", numDronesToRemove, fitID)
fit = eos.db.getFit(fitID)
d = fit.drones[i]
d.amount -= numDronesToRemove
@@ -783,6 +832,7 @@ class Fit(object):
return True
def toggleDrone(self, fitID, i):
pyfalog.debug("Toggling drones for fit ID: {0}", fitID)
fit = eos.db.getFit(fitID)
d = fit.drones[i]
if d.amount == d.amountActive:
@@ -795,6 +845,7 @@ class Fit(object):
return True
def toggleFighter(self, fitID, i):
pyfalog.debug("Toggling fighters for fit ID: {0}", fitID)
fit = eos.db.getFit(fitID)
f = fit.fighters[i]
f.active = not f.active
@@ -804,6 +855,7 @@ class Fit(object):
return True
def toggleImplant(self, fitID, i):
pyfalog.debug("Toggling implant for fit ID: {0}", fitID)
fit = eos.db.getFit(fitID)
implant = fit.implants[i]
implant.active = not implant.active
@@ -813,6 +865,7 @@ class Fit(object):
return True
def toggleImplantSource(self, fitID, source):
pyfalog.debug("Toggling implant source for fit ID: {0}", fitID)
fit = eos.db.getFit(fitID)
fit.implantSource = source
@@ -821,6 +874,7 @@ class Fit(object):
return True
def toggleBooster(self, fitID, i):
pyfalog.debug("Toggling booster for fit ID: {0}", fitID)
fit = eos.db.getFit(fitID)
booster = fit.boosters[i]
booster.active = not booster.active
@@ -830,12 +884,14 @@ class Fit(object):
return True
def toggleFighterAbility(self, fitID, ability):
pyfalog.debug("Toggling fighter ability for fit ID: {0}", fitID)
fit = eos.db.getFit(fitID)
ability.active = not ability.active
eos.db.commit()
self.recalc(fit)
def changeChar(self, fitID, charID):
pyfalog.debug("Changing character ({0}) for fit ID: {1}", charID, fitID)
if fitID is None or charID is None:
if charID is not None:
self.character = Character.getInstance().all5()
@@ -851,6 +907,7 @@ class Fit(object):
return eos.db.getItem(itemID).category.name == "Charge"
def setAmmo(self, fitID, ammoID, modules):
pyfalog.debug("Set ammo for fit ID: {0}", fitID)
if fitID is None:
return
@@ -865,6 +922,7 @@ class Fit(object):
@staticmethod
def getTargetResists(fitID):
pyfalog.debug("Get target resists for fit ID: {0}", fitID)
if fitID is None:
return
@@ -872,6 +930,7 @@ class Fit(object):
return fit.targetResists
def setTargetResists(self, fitID, pattern):
pyfalog.debug("Set target resist for fit ID: {0}", fitID)
if fitID is None:
return
@@ -883,6 +942,7 @@ class Fit(object):
@staticmethod
def getDamagePattern(fitID):
pyfalog.debug("Get damage pattern for fit ID: {0}", fitID)
if fitID is None:
return
@@ -890,6 +950,7 @@ class Fit(object):
return fit.damagePattern
def setDamagePattern(self, fitID, pattern):
pyfalog.debug("Set damage pattern for fit ID: {0}", fitID)
if fitID is None:
return
@@ -900,6 +961,7 @@ class Fit(object):
self.recalc(fit)
def setMode(self, fitID, mode):
pyfalog.debug("Set mode for fit ID: {0}", fitID)
if fitID is None:
return
@@ -910,6 +972,7 @@ class Fit(object):
self.recalc(fit)
def setAsPattern(self, fitID, ammo):
pyfalog.debug("Set as pattern for fit ID: {0}", fitID)
if fitID is None:
return
@@ -927,6 +990,7 @@ class Fit(object):
self.recalc(fit)
def checkStates(self, fit, base):
pyfalog.debug("Check states for fit ID: {0}", fit)
changed = False
for mod in fit.modules:
if mod != base:
@@ -951,6 +1015,7 @@ class Fit(object):
self.recalc(fit)
def toggleModulesState(self, fitID, base, modules, click):
pyfalog.debug("Toggle module state for fit ID: {0}", fitID)
changed = False
proposedState = self.__getProposedState(base, click)
@@ -990,6 +1055,7 @@ class Fit(object):
State.ONLINE: State.OFFLINE}
def __getProposedState(self, mod, click, proposedState=None):
pyfalog.debug("Get proposed state for module.")
if mod.slot == Slot.SUBSYSTEM or mod.isEmpty:
return State.ONLINE
@@ -1017,6 +1083,7 @@ class Fit(object):
return currState
def refreshFit(self, fitID):
pyfalog.debug("Refresh fit for fit ID: {0}", fitID)
if fitID is None:
return None
@@ -1025,9 +1092,12 @@ class Fit(object):
self.recalc(fit)
def recalc(self, fit, withBoosters=True):
start_time = time()
pyfalog.info("=" * 10 + "recalc" + "=" * 10)
if fit.factorReload is not self.serviceFittingOptions["useGlobalForceReload"]:
fit.factorReload = self.serviceFittingOptions["useGlobalForceReload"]
fit.clear()
fit.calculateModifiedAttributes(withBoosters=False)
pyfalog.info("=" * 10 + "recalc time: " + str(time() - start_time) + "=" * 10)

View File

@@ -229,6 +229,7 @@ class Market(object):
"Apotheosis" : self.les_grp, # 5th EVE anniversary present
"Zephyr" : self.les_grp, # 2010 new year gift
"Primae" : self.les_grp, # Promotion of planetary interaction
"Council Diplomatic Shuttle" : self.les_grp, # CSM X celebration
"Freki" : self.les_grp, # AT7 prize
"Mimir" : self.les_grp, # AT7 prize
"Utu" : self.les_grp, # AT8 prize
@@ -274,7 +275,6 @@ class Market(object):
"Guristas Shuttle" : False,
"Mobile Decoy Unit" : False, # Seems to be left over test mod for deployables
"Tournament Micro Jump Unit" : False, # Normally seen only on tournament arenas
"Council Diplomatic Shuttle" : False, # CSM X celebration
"Civilian Gatling Railgun" : True,
"Civilian Gatling Pulse Laser" : True,
"Civilian Gatling Autocannon" : True,

View File

@@ -21,10 +21,13 @@
import urllib2
import urllib
import socket
from logbook import Logger
import config
from service.settings import NetworkSettings
pyfalog = Logger(__name__)
# network timeout, otherwise pyfa hangs for a long while if no internet connection
timeout = 3
socket.setdefaulttimeout(timeout)
@@ -76,6 +79,7 @@ class Network(object):
access = NetworkSettings.getInstance().getAccess()
if not self.ENABLED & access or not type & access:
pyfalog.warning("Access not enabled - please enable in Preferences > Network")
raise Error("Access not enabled - please enable in Preferences > Network")
# Set up some things for the request
@@ -113,6 +117,8 @@ class Network(object):
try:
return urllib2.urlopen(request)
except urllib2.HTTPError as error:
pyfalog.warning("HTTPError:")
pyfalog.warning(error)
if error.code == 404:
raise RequestError()
elif error.code == 403:
@@ -120,6 +126,8 @@ class Network(object):
elif error.code >= 500:
raise ServerError()
except urllib2.URLError as error:
pyfalog.warning("Timed out or other URL error:")
pyfalog.warning(error)
if "timed out" in error.reason:
raise TimeoutError()
else:

View File

@@ -83,11 +83,13 @@ class Port(object):
@staticmethod
def backupFits(path, callback):
pyfalog.debug("Starting backup fits thread.")
thread = FitBackupThread(path, callback)
thread.start()
@staticmethod
def importFitsThreaded(paths, callback):
pyfalog.debug("Starting import fits thread.")
thread = FitImportThread(paths, callback)
thread.start()
@@ -105,12 +107,14 @@ class Port(object):
fits = []
for path in paths:
if callback: # Pulse
pyfalog.debug("Processing file:\n{0}", path)
wx.CallAfter(callback, 1, "Processing file:\n%s" % path)
file_ = open(path, "r")
srcString = file_.read()
if len(srcString) == 0: # ignore blank files
pyfalog.debug("File is blank.")
continue
codec_found = None
@@ -165,6 +169,7 @@ class Port(object):
_, fitsImport = Port.importAuto(srcString, path, callback=callback, encoding=codec_found)
fits += fitsImport
except xml.parsers.expat.ExpatError:
pyfalog.warning("Malformed XML in:\n{0}", path)
return False, "Malformed XML in %s" % path
except Exception as e:
pyfalog.critical("Unknown exception processing: {0}", path)
@@ -181,6 +186,7 @@ class Port(object):
db.save(fit)
IDs.append(fit.ID)
if callback: # Pulse
pyfalog.debug("Processing complete, saving fits to database: {0}/{1}", i + 1, numFits)
wx.CallAfter(
callback, 1,
"Processing complete, saving fits to database\n(%d/%d)" %
@@ -612,7 +618,7 @@ class Port(object):
if m.fits(fit):
m.owner = fit
if not m.isValidState(m.state):
print("Error: Module", m, "cannot have state", m.state)
pyfalog.warning("Error: Module {0} cannot have state {1}", m, m.state)
fit.modules.append(m)
@@ -810,8 +816,9 @@ class Port(object):
if callback:
wx.CallAfter(callback, None)
# Skip fit silently if we get an exception
except Exception:
except Exception as e:
pyfalog.error("Caught exception on fit.")
pyfalog.error(e)
pass
return fits
@@ -835,8 +842,9 @@ class Port(object):
f.ship = Ship(sMkt.getItem(shipType))
except ValueError:
f.ship = Citadel(sMkt.getItem(shipType))
except:
except Exception as e:
pyfalog.warning("Caught exception on importXml")
pyfalog.error(e)
continue
hardwares = fitting.getElementsByTagName("hardware")
moduleList = []
@@ -845,8 +853,9 @@ class Port(object):
moduleName = hardware.getAttribute("type")
try:
item = sMkt.getItem(moduleName, eager="group.category")
except:
except Exception as e:
pyfalog.warning("Caught exception on importXml")
pyfalog.error(e)
continue
if item:
if item.category.name == "Drone":

View File

@@ -59,6 +59,7 @@ if config.saveDB and os.path.isfile(config.saveDB):
else:
# If database does not exist, do not worry about migration. Simply
# create and set version
pyfalog.debug("Existing database not found, creating new database.")
db.saveddata_meta.create_all()
db.saveddata_engine.execute('PRAGMA user_version = {}'.format(migration.getAppVersion()))
# Import default database values

View File

@@ -104,6 +104,7 @@ class Price(object):
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

View File

@@ -82,11 +82,15 @@ class AuthHandler(BaseHTTPServer.BaseHTTPRequestHandler):
try:
if step2:
self.server.callback(parts)
pyfalog.info("Successfully logged into CREST.")
msg = "If you see this message then it means you should be logged into CREST. You may close this window and return to the application."
else:
# For implicit mode, we have to serve up the page which will take the hash and redirect useing a querystring
pyfalog.info("Processing response from EVE Online.")
msg = "Processing response from EVE Online"
except Exception, ex:
pyfalog.error("Error in CREST AuthHandler")
pyfalog.error(ex)
msg = "<h2>Error</h2>\n<p>{}</p>".format(ex.message)
finally:
self.send_response(200)
@@ -127,6 +131,7 @@ class StoppableHTTPServer(BaseHTTPServer.HTTPServer):
pass
def stop(self):
pyfalog.warning("Setting CREST server to stop.")
self.run = False
def handle_timeout(self):

View File

@@ -22,13 +22,15 @@ import os.path
import urllib2
import config
import eos.config
from logbook import Logger
pyfalog = Logger(__name__)
class SettingsProvider(object):
BASE_PATH = os.path.join(config.savePath, 'settings')
if config.savePath:
BASE_PATH = os.path.join(config.savePath, 'settings')
settings = {}
_instance = None
@@ -40,13 +42,15 @@ class SettingsProvider(object):
return cls._instance
def __init__(self):
if not os.path.exists(self.BASE_PATH):
os.mkdir(self.BASE_PATH)
if hasattr(self, 'BASE_PATH'):
if not os.path.exists(self.BASE_PATH):
os.mkdir(self.BASE_PATH)
def getSettings(self, area, defaults=None):
s = self.settings.get(area)
if s is None:
if s is None and hasattr(self, 'BASE_PATH'):
p = os.path.join(self.BASE_PATH, area)
if not os.path.exists(p):
@@ -370,7 +374,8 @@ class StatViewSettings(object):
"targetingMisc": 1,
"price" : 2,
"miningyield" : 2,
"drones" : 2
"drones" : 2,
"outgoing" : 2,
}
# We don't have these....yet
@@ -406,14 +411,17 @@ class ContextMenuSettings(object):
"ammoPattern" : 1,
"amount" : 1,
"cargo" : 1,
"cargoAmmo" : 1,
"changeAffectingSkills" : 1,
"damagePattern" : 1,
"droneRemoveStack" : 1,
"droneSplit" : 1,
"droneStack" : 1,
"factorReload" : 1,
"fighterAbilities" : 1,
"implantSet" : 1,
"implantSets" : 1,
"itemStats" : 1,
"itemRemove" : 1,
"marketJump" : 1,
"metaSwap" : 1,
"moduleAmmoPicker" : 1,
@@ -435,4 +443,24 @@ class ContextMenuSettings(object):
def set(self, type, value):
self.ContextMenuDefaultSettings[type] = value
class EOSSettings(object):
_instance = None
@classmethod
def getInstance(cls):
if cls._instance is None:
cls._instance = EOSSettings()
return cls._instance
def __init__(self):
self.EOSSettings = SettingsProvider.getInstance().getSettings("pyfaEOSSettings", eos.config.settings)
def get(self, type):
return self.EOSSettings[type]
def set(self, type, value):
self.EOSSettings[type] = value
# @todo: migrate fit settings (from fit service) here?

View File

@@ -85,8 +85,9 @@ class CheckUpdateThread(threading.Thread):
if release['prerelease'] and rVersion > config.expansionVersion:
wx.CallAfter(self.callback, release) # Singularity -> Singularity
break
except:
pyfalog.warning("Caught exception in run")
except Exception as e:
pyfalog.error("Caught exception in run")
pyfalog.error(e)
pass
@staticmethod
@@ -100,6 +101,7 @@ class Update(object):
@staticmethod
def CheckUpdate(callback):
thread = CheckUpdateThread(callback)
pyfalog.debug("Starting Check Update Thread.")
thread.start()
@classmethod