Do not crash when facing unknown module in saved fit
This commit is contained in:
@@ -20,7 +20,6 @@
|
|||||||
from logbook import Logger
|
from logbook import Logger
|
||||||
|
|
||||||
from eos.exception import HandledListActionError
|
from eos.exception import HandledListActionError
|
||||||
from utils.deprecated import deprecated
|
|
||||||
|
|
||||||
|
|
||||||
pyfalog = Logger(__name__)
|
pyfalog = Logger(__name__)
|
||||||
@@ -123,7 +122,7 @@ class HandledList(list):
|
|||||||
|
|
||||||
class HandledModuleList(HandledList):
|
class HandledModuleList(HandledList):
|
||||||
|
|
||||||
def append(self, mod):
|
def append(self, mod, raiseFailure=False):
|
||||||
emptyPosition = float("Inf")
|
emptyPosition = float("Inf")
|
||||||
for i in range(len(self)):
|
for i in range(len(self)):
|
||||||
currMod = self[i]
|
currMod = self[i]
|
||||||
@@ -137,29 +136,41 @@ class HandledModuleList(HandledList):
|
|||||||
self.__toModule(emptyPosition, mod)
|
self.__toModule(emptyPosition, mod)
|
||||||
if mod.isInvalid:
|
if mod.isInvalid:
|
||||||
self.__toDummy(mod.position)
|
self.__toDummy(mod.position)
|
||||||
raise HandledListActionError(mod)
|
if raiseFailure:
|
||||||
|
raise HandledListActionError(mod)
|
||||||
|
else:
|
||||||
|
return
|
||||||
return
|
return
|
||||||
|
|
||||||
self.appendIgnoreEmpty(mod)
|
self.appendIgnoreEmpty(mod, raiseFailure=raiseFailure)
|
||||||
|
|
||||||
def appendIgnoreEmpty(self, mod):
|
def appendIgnoreEmpty(self, mod, raiseFailure=False):
|
||||||
mod.position = len(self)
|
mod.position = len(self)
|
||||||
HandledList.append(self, mod)
|
HandledList.append(self, mod)
|
||||||
if mod.isInvalid:
|
if mod.isInvalid:
|
||||||
self.remove(mod)
|
self.remove(mod)
|
||||||
raise HandledListActionError(mod)
|
if raiseFailure:
|
||||||
|
raise HandledListActionError(mod)
|
||||||
|
else:
|
||||||
|
return
|
||||||
|
|
||||||
def replace(self, idx, mod):
|
def replace(self, idx, mod, raiseFailure=False):
|
||||||
try:
|
try:
|
||||||
oldMod = self[idx]
|
oldMod = self[idx]
|
||||||
except IndexError:
|
except IndexError:
|
||||||
raise HandledListActionError(mod)
|
if raiseFailure:
|
||||||
|
raise HandledListActionError(mod)
|
||||||
|
else:
|
||||||
|
return
|
||||||
self.__toModule(idx, mod)
|
self.__toModule(idx, mod)
|
||||||
if mod.isInvalid:
|
if mod.isInvalid:
|
||||||
self.__toModule(idx, oldMod)
|
self.__toModule(idx, oldMod)
|
||||||
raise HandledListActionError(mod)
|
if raiseFailure:
|
||||||
|
raise HandledListActionError(mod)
|
||||||
|
else:
|
||||||
|
return
|
||||||
|
|
||||||
def replaceRackPosition(self, rackPosition, mod):
|
def replaceRackPosition(self, rackPosition, mod, raiseFailure=False):
|
||||||
listPositions = []
|
listPositions = []
|
||||||
for currPos in range(len(self)):
|
for currPos in range(len(self)):
|
||||||
currMod = self[currPos]
|
currMod = self[currPos]
|
||||||
@@ -169,7 +180,7 @@ class HandledModuleList(HandledList):
|
|||||||
try:
|
try:
|
||||||
modListPosition = listPositions[rackPosition]
|
modListPosition = listPositions[rackPosition]
|
||||||
except IndexError:
|
except IndexError:
|
||||||
self.appendIgnoreEmpty(mod)
|
self.appendIgnoreEmpty(mod, raiseFailure=raiseFailure)
|
||||||
else:
|
else:
|
||||||
oldMod = self[modListPosition]
|
oldMod = self[modListPosition]
|
||||||
if mod.isEmpty:
|
if mod.isEmpty:
|
||||||
@@ -182,9 +193,12 @@ class HandledModuleList(HandledList):
|
|||||||
self.__toDummy(modListPosition)
|
self.__toDummy(modListPosition)
|
||||||
else:
|
else:
|
||||||
self.__toModule(modListPosition, oldMod)
|
self.__toModule(modListPosition, oldMod)
|
||||||
raise HandledListActionError(mod)
|
if raiseFailure:
|
||||||
|
raise HandledListActionError(mod)
|
||||||
|
else:
|
||||||
|
return
|
||||||
|
|
||||||
def insert(self, idx, mod):
|
def insert(self, idx, mod, raiseFailure=False):
|
||||||
mod.position = idx
|
mod.position = idx
|
||||||
i = idx
|
i = idx
|
||||||
while i < len(self):
|
while i < len(self):
|
||||||
@@ -193,8 +207,10 @@ class HandledModuleList(HandledList):
|
|||||||
HandledList.insert(self, idx, mod)
|
HandledList.insert(self, idx, mod)
|
||||||
if mod.isInvalid:
|
if mod.isInvalid:
|
||||||
self.remove(mod)
|
self.remove(mod)
|
||||||
raise HandledListActionError(mod)
|
if raiseFailure:
|
||||||
|
raise HandledListActionError(mod)
|
||||||
|
else:
|
||||||
|
return
|
||||||
|
|
||||||
def remove(self, mod):
|
def remove(self, mod):
|
||||||
HandledList.remove(self, mod)
|
HandledList.remove(self, mod)
|
||||||
@@ -232,41 +248,59 @@ class HandledDroneCargoList(HandledList):
|
|||||||
for o in self.find(item):
|
for o in self.find(item):
|
||||||
return o
|
return o
|
||||||
|
|
||||||
def append(self, thing):
|
def append(self, thing, raiseFailure=False):
|
||||||
HandledList.append(self, thing)
|
HandledList.append(self, thing)
|
||||||
if thing.isInvalid:
|
if thing.isInvalid:
|
||||||
self.remove(thing)
|
self.remove(thing)
|
||||||
raise HandledListActionError(thing)
|
if raiseFailure:
|
||||||
|
raise HandledListActionError(thing)
|
||||||
|
else:
|
||||||
|
return
|
||||||
|
|
||||||
def insert(self, idx, thing):
|
def insert(self, idx, thing, raiseFailure=False):
|
||||||
HandledList.insert(self, idx, thing)
|
HandledList.insert(self, idx, thing)
|
||||||
if thing.isInvalid:
|
if thing.isInvalid:
|
||||||
self.remove(thing)
|
self.remove(thing)
|
||||||
raise HandledListActionError(thing)
|
if raiseFailure:
|
||||||
|
raise HandledListActionError(thing)
|
||||||
|
else:
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
class HandledImplantList(HandledList):
|
class HandledImplantList(HandledList):
|
||||||
|
|
||||||
def append(self, implant):
|
def append(self, implant, raiseFailure=False):
|
||||||
if implant.isInvalid:
|
if implant.isInvalid:
|
||||||
HandledList.append(self, implant)
|
HandledList.append(self, implant)
|
||||||
self.remove(implant)
|
self.remove(implant)
|
||||||
raise HandledListActionError(implant)
|
if raiseFailure:
|
||||||
|
raise HandledListActionError(implant)
|
||||||
|
else:
|
||||||
|
return
|
||||||
if self.__slotCheck(implant):
|
if self.__slotCheck(implant):
|
||||||
HandledList.append(self, implant)
|
HandledList.append(self, implant)
|
||||||
self.remove(implant)
|
self.remove(implant)
|
||||||
raise HandledListActionError(implant)
|
if raiseFailure:
|
||||||
|
raise HandledListActionError(implant)
|
||||||
|
else:
|
||||||
|
return
|
||||||
HandledList.append(self, implant)
|
HandledList.append(self, implant)
|
||||||
|
|
||||||
def insert(self, idx, implant):
|
def insert(self, idx, implant, raiseFailure=False):
|
||||||
if implant.isInvalid:
|
if implant.isInvalid:
|
||||||
HandledList.insert(self, idx, implant)
|
HandledList.insert(self, idx, implant)
|
||||||
self.remove(implant)
|
self.remove(implant)
|
||||||
raise HandledListActionError(implant)
|
if raiseFailure:
|
||||||
|
raise HandledListActionError(implant)
|
||||||
|
else:
|
||||||
|
return
|
||||||
if self.__slotCheck(implant):
|
if self.__slotCheck(implant):
|
||||||
HandledList.insert(self, idx, implant)
|
HandledList.insert(self, idx, implant)
|
||||||
self.remove(implant)
|
self.remove(implant)
|
||||||
raise HandledListActionError(implant)
|
if raiseFailure:
|
||||||
|
raise HandledListActionError(implant)
|
||||||
|
else:
|
||||||
|
return
|
||||||
HandledList.insert(self, idx, implant)
|
HandledList.insert(self, idx, implant)
|
||||||
|
|
||||||
def makeRoom(self, implant):
|
def makeRoom(self, implant):
|
||||||
@@ -288,26 +322,38 @@ class HandledImplantList(HandledList):
|
|||||||
|
|
||||||
class HandledBoosterList(HandledList):
|
class HandledBoosterList(HandledList):
|
||||||
|
|
||||||
def append(self, booster):
|
def append(self, booster, raiseFailure=False):
|
||||||
if booster.isInvalid:
|
if booster.isInvalid:
|
||||||
HandledList.append(self, booster)
|
HandledList.append(self, booster)
|
||||||
self.remove(booster)
|
self.remove(booster)
|
||||||
raise HandledListActionError(booster)
|
if raiseFailure:
|
||||||
|
raise HandledListActionError(booster)
|
||||||
|
else:
|
||||||
|
return
|
||||||
if self.__slotCheck(booster):
|
if self.__slotCheck(booster):
|
||||||
HandledList.append(self, booster)
|
HandledList.append(self, booster)
|
||||||
self.remove(booster)
|
self.remove(booster)
|
||||||
raise HandledListActionError(booster)
|
if raiseFailure:
|
||||||
|
raise HandledListActionError(booster)
|
||||||
|
else:
|
||||||
|
return
|
||||||
HandledList.append(self, booster)
|
HandledList.append(self, booster)
|
||||||
|
|
||||||
def insert(self, idx, booster):
|
def insert(self, idx, booster, raiseFailure=False):
|
||||||
if booster.isInvalid:
|
if booster.isInvalid:
|
||||||
HandledList.insert(self, idx, booster)
|
HandledList.insert(self, idx, booster)
|
||||||
self.remove(booster)
|
self.remove(booster)
|
||||||
raise HandledListActionError(booster)
|
if raiseFailure:
|
||||||
|
raise HandledListActionError(booster)
|
||||||
|
else:
|
||||||
|
return
|
||||||
if self.__slotCheck(booster):
|
if self.__slotCheck(booster):
|
||||||
HandledList.insert(self, idx, booster)
|
HandledList.insert(self, idx, booster)
|
||||||
self.remove(booster)
|
self.remove(booster)
|
||||||
raise HandledListActionError(booster)
|
if raiseFailure:
|
||||||
|
raise HandledListActionError(booster)
|
||||||
|
else:
|
||||||
|
return
|
||||||
HandledList.insert(self, idx, booster)
|
HandledList.insert(self, idx, booster)
|
||||||
|
|
||||||
def makeRoom(self, booster):
|
def makeRoom(self, booster):
|
||||||
@@ -340,13 +386,16 @@ class HandledSsoCharacterList(list):
|
|||||||
|
|
||||||
class HandledProjectedModList(HandledList):
|
class HandledProjectedModList(HandledList):
|
||||||
|
|
||||||
def append(self, proj):
|
def append(self, proj, raiseFailure=False):
|
||||||
if proj.isInvalid:
|
if proj.isInvalid:
|
||||||
# we must include it before we remove it. doing it this way ensures
|
# we must include it before we remove it. doing it this way ensures
|
||||||
# rows and relationships in database are removed as well
|
# rows and relationships in database are removed as well
|
||||||
HandledList.append(self, proj)
|
HandledList.append(self, proj)
|
||||||
self.remove(proj)
|
self.remove(proj)
|
||||||
raise HandledListActionError(proj)
|
if raiseFailure:
|
||||||
|
raise HandledListActionError(proj)
|
||||||
|
else:
|
||||||
|
return
|
||||||
|
|
||||||
proj.projected = True
|
proj.projected = True
|
||||||
|
|
||||||
@@ -355,15 +404,21 @@ class HandledProjectedModList(HandledList):
|
|||||||
# Remove non-projectable modules
|
# Remove non-projectable modules
|
||||||
if not proj.item.isType("projected") and not proj.isExclusiveSystemEffect:
|
if not proj.item.isType("projected") and not proj.isExclusiveSystemEffect:
|
||||||
self.remove(proj)
|
self.remove(proj)
|
||||||
raise HandledListActionError(proj)
|
if raiseFailure:
|
||||||
|
raise HandledListActionError(proj)
|
||||||
|
else:
|
||||||
|
return
|
||||||
|
|
||||||
def insert(self, idx, proj):
|
def insert(self, idx, proj, raiseFailure=False):
|
||||||
if proj.isInvalid:
|
if proj.isInvalid:
|
||||||
# we must include it before we remove it. doing it this way ensures
|
# we must include it before we remove it. doing it this way ensures
|
||||||
# rows and relationships in database are removed as well
|
# rows and relationships in database are removed as well
|
||||||
HandledList.insert(self, idx, proj)
|
HandledList.insert(self, idx, proj)
|
||||||
self.remove(proj)
|
self.remove(proj)
|
||||||
raise HandledListActionError(proj)
|
if raiseFailure:
|
||||||
|
raise HandledListActionError(proj)
|
||||||
|
else:
|
||||||
|
return
|
||||||
|
|
||||||
proj.projected = True
|
proj.projected = True
|
||||||
|
|
||||||
@@ -372,7 +427,10 @@ class HandledProjectedModList(HandledList):
|
|||||||
# Remove non-projectable modules
|
# Remove non-projectable modules
|
||||||
if not proj.item.isType("projected") and not proj.isExclusiveSystemEffect:
|
if not proj.item.isType("projected") and not proj.isExclusiveSystemEffect:
|
||||||
self.remove(proj)
|
self.remove(proj)
|
||||||
raise HandledListActionError(proj)
|
if raiseFailure:
|
||||||
|
raise HandledListActionError(proj)
|
||||||
|
else:
|
||||||
|
return
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def currentSystemEffect(self):
|
def currentSystemEffect(self):
|
||||||
@@ -396,7 +454,7 @@ class HandledProjectedModList(HandledList):
|
|||||||
|
|
||||||
class HandledProjectedDroneList(HandledDroneCargoList):
|
class HandledProjectedDroneList(HandledDroneCargoList):
|
||||||
|
|
||||||
def append(self, proj):
|
def append(self, proj, raiseFailure=False):
|
||||||
proj.projected = True
|
proj.projected = True
|
||||||
HandledList.append(self, proj)
|
HandledList.append(self, proj)
|
||||||
|
|
||||||
@@ -404,10 +462,12 @@ class HandledProjectedDroneList(HandledDroneCargoList):
|
|||||||
if proj.isInvalid or not proj.item.isType("projected"):
|
if proj.isInvalid or not proj.item.isType("projected"):
|
||||||
self.remove(proj)
|
self.remove(proj)
|
||||||
proj.projected = False
|
proj.projected = False
|
||||||
raise HandledListActionError(proj)
|
if raiseFailure:
|
||||||
return True
|
raise HandledListActionError(proj)
|
||||||
|
else:
|
||||||
|
return
|
||||||
|
|
||||||
def insert(self, idx, proj):
|
def insert(self, idx, proj, raiseFailure=False):
|
||||||
proj.projected = True
|
proj.projected = True
|
||||||
HandledList.insert(self, idx, proj)
|
HandledList.insert(self, idx, proj)
|
||||||
|
|
||||||
@@ -415,8 +475,10 @@ class HandledProjectedDroneList(HandledDroneCargoList):
|
|||||||
if proj.isInvalid or not proj.item.isType("projected"):
|
if proj.isInvalid or not proj.item.isType("projected"):
|
||||||
self.remove(proj)
|
self.remove(proj)
|
||||||
proj.projected = False
|
proj.projected = False
|
||||||
raise HandledListActionError(proj)
|
if raiseFailure:
|
||||||
return True
|
raise HandledListActionError(proj)
|
||||||
|
else:
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
class HandledItem(object):
|
class HandledItem(object):
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ class CalcAddBoosterCommand(wx.Command):
|
|||||||
|
|
||||||
if self.newPosition is not None:
|
if self.newPosition is not None:
|
||||||
try:
|
try:
|
||||||
fit.boosters.insert(self.newPosition, newBooster)
|
fit.boosters.insert(self.newPosition, newBooster, raiseFailure=True)
|
||||||
except HandledListActionError:
|
except HandledListActionError:
|
||||||
pyfalog.warning('Failed to insert to list')
|
pyfalog.warning('Failed to insert to list')
|
||||||
cmd = CalcAddBoosterCommand(
|
cmd = CalcAddBoosterCommand(
|
||||||
@@ -48,7 +48,7 @@ class CalcAddBoosterCommand(wx.Command):
|
|||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
fit.boosters.append(newBooster)
|
fit.boosters.append(newBooster, raiseFailure=True)
|
||||||
except HandledListActionError:
|
except HandledListActionError:
|
||||||
pyfalog.warning('Failed to append to list')
|
pyfalog.warning('Failed to append to list')
|
||||||
cmd = CalcAddBoosterCommand(
|
cmd = CalcAddBoosterCommand(
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ class CalcAddCargoCommand(wx.Command):
|
|||||||
else:
|
else:
|
||||||
cargo = self.cargoInfo.toCargo()
|
cargo = self.cargoInfo.toCargo()
|
||||||
try:
|
try:
|
||||||
fit.cargo.append(cargo)
|
fit.cargo.append(cargo, raiseFailure=True)
|
||||||
except HandledListActionError:
|
except HandledListActionError:
|
||||||
pyfalog.warning('Failed to append to list')
|
pyfalog.warning('Failed to append to list')
|
||||||
if self.commit:
|
if self.commit:
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ class CalcAddLocalDroneCommand(wx.Command):
|
|||||||
pyfalog.warning('Drone does not fit')
|
pyfalog.warning('Drone does not fit')
|
||||||
return False
|
return False
|
||||||
try:
|
try:
|
||||||
fit.drones.append(drone)
|
fit.drones.append(drone, raiseFailure=True)
|
||||||
except HandledListActionError:
|
except HandledListActionError:
|
||||||
pyfalog.warning('Failed to append to list')
|
pyfalog.warning('Failed to append to list')
|
||||||
if self.commit:
|
if self.commit:
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ class CalcRemoveLocalDroneCommand(wx.Command):
|
|||||||
if drone is None:
|
if drone is None:
|
||||||
return False
|
return False
|
||||||
try:
|
try:
|
||||||
fit.drones.insert(self.position, drone)
|
fit.drones.insert(self.position, drone, raiseFailure=True)
|
||||||
except HandledListActionError:
|
except HandledListActionError:
|
||||||
pyfalog.warning('Failed to insert to list')
|
pyfalog.warning('Failed to insert to list')
|
||||||
if self.commit:
|
if self.commit:
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ class CalcAddProjectedDroneCommand(wx.Command):
|
|||||||
pyfalog.debug('Drone is not projectable')
|
pyfalog.debug('Drone is not projectable')
|
||||||
return False
|
return False
|
||||||
try:
|
try:
|
||||||
fit.projectedDrones.append(drone)
|
fit.projectedDrones.append(drone, raiseFailure=True)
|
||||||
except HandledListActionError:
|
except HandledListActionError:
|
||||||
pyfalog.warning('Failed to append to list')
|
pyfalog.warning('Failed to append to list')
|
||||||
if self.commit:
|
if self.commit:
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ class CalcAddLocalFighterCommand(wx.Command):
|
|||||||
|
|
||||||
if self.position is None:
|
if self.position is None:
|
||||||
try:
|
try:
|
||||||
fit.fighters.append(fighter)
|
fit.fighters.append(fighter, raiseFailure=True)
|
||||||
except HandledListActionError:
|
except HandledListActionError:
|
||||||
pyfalog.warning('Failed to append to list')
|
pyfalog.warning('Failed to append to list')
|
||||||
if self.commit:
|
if self.commit:
|
||||||
@@ -51,7 +51,7 @@ class CalcAddLocalFighterCommand(wx.Command):
|
|||||||
self.position = fit.fighters.index(fighter)
|
self.position = fit.fighters.index(fighter)
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
fit.fighters.insert(self.position, fighter)
|
fit.fighters.insert(self.position, fighter, raiseFailure=True)
|
||||||
except HandledListActionError:
|
except HandledListActionError:
|
||||||
pyfalog.warning('Failed to insert to list')
|
pyfalog.warning('Failed to insert to list')
|
||||||
if self.commit:
|
if self.commit:
|
||||||
|
|||||||
@@ -26,14 +26,14 @@ class CalcAddProjectedFighterCommand(wx.Command):
|
|||||||
fit = Fit.getInstance().getFit(self.fitID)
|
fit = Fit.getInstance().getFit(self.fitID)
|
||||||
if self.position is not None:
|
if self.position is not None:
|
||||||
try:
|
try:
|
||||||
fit.projectedFighters.insert(self.position, fighter)
|
fit.projectedFighters.insert(self.position, fighter, raiseFailure=True)
|
||||||
except HandledListActionError:
|
except HandledListActionError:
|
||||||
if self.commit:
|
if self.commit:
|
||||||
eos.db.commit()
|
eos.db.commit()
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
fit.projectedFighters.append(fighter)
|
fit.projectedFighters.append(fighter, raiseFailure=True)
|
||||||
except HandledListActionError:
|
except HandledListActionError:
|
||||||
if self.commit:
|
if self.commit:
|
||||||
eos.db.commit()
|
eos.db.commit()
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ class CalcAddImplantCommand(wx.Command):
|
|||||||
|
|
||||||
if self.newPosition is not None:
|
if self.newPosition is not None:
|
||||||
try:
|
try:
|
||||||
fit.implants.insert(self.newPosition, newImplant)
|
fit.implants.insert(self.newPosition, newImplant, raiseFailure=True)
|
||||||
except HandledListActionError:
|
except HandledListActionError:
|
||||||
pyfalog.warning('Failed to insert to list')
|
pyfalog.warning('Failed to insert to list')
|
||||||
cmd = CalcAddImplantCommand(
|
cmd = CalcAddImplantCommand(
|
||||||
@@ -48,7 +48,7 @@ class CalcAddImplantCommand(wx.Command):
|
|||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
fit.implants.append(newImplant)
|
fit.implants.append(newImplant, raiseFailure=True)
|
||||||
except HandledListActionError:
|
except HandledListActionError:
|
||||||
pyfalog.warning('Failed to append to list')
|
pyfalog.warning('Failed to append to list')
|
||||||
cmd = CalcAddImplantCommand(
|
cmd = CalcAddImplantCommand(
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ class CalcAddLocalModuleCommand(wx.Command):
|
|||||||
pyfalog.warning('Module does not fit')
|
pyfalog.warning('Module does not fit')
|
||||||
return False
|
return False
|
||||||
try:
|
try:
|
||||||
fit.modules.append(newMod)
|
fit.modules.append(newMod, raiseFailure=True)
|
||||||
except HandledListActionError:
|
except HandledListActionError:
|
||||||
pyfalog.warning('Failed to append to list')
|
pyfalog.warning('Failed to append to list')
|
||||||
if self.commit:
|
if self.commit:
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ class CalcCloneLocalModuleCommand(wx.Command):
|
|||||||
if not fit.modules[self.dstPosition].isEmpty:
|
if not fit.modules[self.dstPosition].isEmpty:
|
||||||
return False
|
return False
|
||||||
try:
|
try:
|
||||||
fit.modules.replace(self.dstPosition, copyMod)
|
fit.modules.replace(self.dstPosition, copyMod, raiseFailure=True)
|
||||||
except HandledListActionError:
|
except HandledListActionError:
|
||||||
pyfalog.warning('Failed to replace module')
|
pyfalog.warning('Failed to replace module')
|
||||||
eos.db.commit()
|
eos.db.commit()
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ class CalcReplaceLocalModuleCommand(wx.Command):
|
|||||||
self.Undo()
|
self.Undo()
|
||||||
return False
|
return False
|
||||||
try:
|
try:
|
||||||
fit.modules.replace(self.position, newMod)
|
fit.modules.replace(self.position, newMod, raiseFailure=True)
|
||||||
except HandledListActionError:
|
except HandledListActionError:
|
||||||
pyfalog.warning('Failed to replace in list')
|
pyfalog.warning('Failed to replace in list')
|
||||||
self.Undo()
|
self.Undo()
|
||||||
@@ -88,7 +88,7 @@ class CalcReplaceLocalModuleCommand(wx.Command):
|
|||||||
return False
|
return False
|
||||||
fit.modules.free(self.position)
|
fit.modules.free(self.position)
|
||||||
try:
|
try:
|
||||||
fit.modules.replace(self.position, oldMod)
|
fit.modules.replace(self.position, oldMod, raiseFailure=True)
|
||||||
except HandledListActionError:
|
except HandledListActionError:
|
||||||
pyfalog.warning('Failed to replace in list')
|
pyfalog.warning('Failed to replace in list')
|
||||||
self.Do()
|
self.Do()
|
||||||
|
|||||||
@@ -34,14 +34,14 @@ class CalcSwapLocalModuleCommand(wx.Command):
|
|||||||
fit.modules.free(position1)
|
fit.modules.free(position1)
|
||||||
fit.modules.free(position2)
|
fit.modules.free(position2)
|
||||||
try:
|
try:
|
||||||
fit.modules.replace(position2, mod1)
|
fit.modules.replace(position2, mod1, raiseFailure=True)
|
||||||
except HandledListActionError:
|
except HandledListActionError:
|
||||||
fit.modules.replace(position1, mod1)
|
fit.modules.replace(position1, mod1)
|
||||||
fit.modules.replace(position2, mod2)
|
fit.modules.replace(position2, mod2)
|
||||||
eos.db.commit()
|
eos.db.commit()
|
||||||
return False
|
return False
|
||||||
try:
|
try:
|
||||||
fit.modules.replace(position1, mod2)
|
fit.modules.replace(position1, mod2, raiseFailure=True)
|
||||||
except HandledListActionError:
|
except HandledListActionError:
|
||||||
fit.modules.free(position2)
|
fit.modules.free(position2)
|
||||||
fit.modules.replace(position1, mod1)
|
fit.modules.replace(position1, mod1)
|
||||||
|
|||||||
@@ -40,14 +40,14 @@ class CalcAddProjectedModuleCommand(wx.Command):
|
|||||||
|
|
||||||
if self.newPosition is not None:
|
if self.newPosition is not None:
|
||||||
try:
|
try:
|
||||||
fit.projectedModules.insert(self.newPosition, newMod)
|
fit.projectedModules.insert(self.newPosition, newMod, raiseFailure=True)
|
||||||
except HandledListActionError:
|
except HandledListActionError:
|
||||||
if self.commit:
|
if self.commit:
|
||||||
eos.db.commit()
|
eos.db.commit()
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
fit.projectedModules.append(newMod)
|
fit.projectedModules.append(newMod, raiseFailure=True)
|
||||||
except HandledListActionError:
|
except HandledListActionError:
|
||||||
if self.commit:
|
if self.commit:
|
||||||
eos.db.commit()
|
eos.db.commit()
|
||||||
|
|||||||
Reference in New Issue
Block a user