From 301e874cd4052ab0d10c0d44be3bb5a945f84f4d Mon Sep 17 00:00:00 2001 From: Ebag333 Date: Fri, 17 Mar 2017 16:05:09 -0700 Subject: [PATCH] Add a ton of logging to the fitting service --- gui/builtinViews/fittingView.py | 8 ++--- gui/shipBrowser.py | 1 + service/fit.py | 61 +++++++++++++++++++++++++++++++++ 3 files changed, 65 insertions(+), 5 deletions(-) diff --git a/gui/builtinViews/fittingView.py b/gui/builtinViews/fittingView.py index 0b64d9d53..496cf4fb8 100644 --- a/gui/builtinViews/fittingView.py +++ b/gui/builtinViews/fittingView.py @@ -268,9 +268,7 @@ class FittingView(d.Display): We also refresh the fit of the new current page in case delete fit caused change in stats (projected) """ - fitID = event.fitID - - if fitID == self.getActiveFit(): + if event.fitID == self.getActiveFit(): self.parent.DeletePage(self.parent.GetPageIndex(self)) try: @@ -279,7 +277,7 @@ class FittingView(d.Display): sFit.refreshFit(self.getActiveFit()) wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.activeFitID)) except wx._core.PyDeadObjectError: - pyfalog.warning("Caught dead object") + pyfalog.error("Caught dead object") pass event.Skip() @@ -485,7 +483,7 @@ class FittingView(d.Display): self.Show(self.activeFitID is not None and self.activeFitID == event.fitID) except wx._core.PyDeadObjectError: - pyfalog.warning("Caught dead object") + pyfalog.error("Caught dead object") finally: event.Skip() diff --git a/gui/shipBrowser.py b/gui/shipBrowser.py index 33561de5b..c61f9b698 100644 --- a/gui/shipBrowser.py +++ b/gui/shipBrowser.py @@ -1746,6 +1746,7 @@ class FitItem(SFItem.SFBrowserItem): self.deleteFit() def deleteFit(self, event=None): + pyfalog.debug("Deleting ship fit.") if self.deleted: return else: diff --git a/service/fit.py b/service/fit.py index 70a471042..0bb385894 100644 --- a/service/fit.py +++ b/service/fit.py @@ -79,12 +79,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: @@ -95,6 +97,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: @@ -104,10 +107,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 @@ -117,6 +122,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: @@ -133,18 +139,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) @@ -157,6 +166,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) @@ -164,6 +174,7 @@ class Fit(object): @staticmethod def clearFit(fitID): + pyfalog.debug("Clearing fit for fit ID: {0}", fitID) if fitID is None: return None @@ -172,6 +183,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 @@ -181,6 +193,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 @@ -204,6 +217,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) @@ -229,6 +243,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: @@ -238,6 +253,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 @@ -255,6 +271,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 @@ -265,6 +282,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 @@ -281,6 +299,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 +310,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 +360,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 +380,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 +402,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 +413,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 +424,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 +432,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 +448,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,6 +456,7 @@ 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: @@ -460,6 +488,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 @@ -473,6 +502,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 @@ -511,6 +541,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] @@ -558,6 +589,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] @@ -577,6 +609,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] @@ -597,6 +630,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 @@ -629,6 +663,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 @@ -639,6 +674,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 @@ -685,6 +721,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) @@ -694,6 +731,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 @@ -720,6 +758,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 @@ -746,6 +785,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 @@ -758,6 +798,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 @@ -765,6 +806,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 @@ -772,6 +814,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 @@ -786,6 +829,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: @@ -798,6 +842,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 @@ -807,6 +852,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 @@ -816,6 +862,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 @@ -824,6 +871,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 @@ -833,12 +881,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() @@ -854,6 +904,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 @@ -868,6 +919,7 @@ class Fit(object): @staticmethod def getTargetResists(fitID): + pyfalog.debug("Get target resists for fit ID: {0}", fitID) if fitID is None: return @@ -875,6 +927,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 @@ -886,6 +939,7 @@ class Fit(object): @staticmethod def getDamagePattern(fitID): + pyfalog.debug("Get damage pattern for fit ID: {0}", fitID) if fitID is None: return @@ -893,6 +947,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 @@ -903,6 +958,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 @@ -913,6 +969,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 @@ -930,6 +987,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: @@ -954,6 +1012,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) @@ -993,6 +1052,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 @@ -1020,6 +1080,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