Merge branch 'development' into ErrorDialog_and_miscfixes

This commit is contained in:
Ebag333
2017-03-27 21:00:51 -07:00
committed by GitHub
19 changed files with 230 additions and 65 deletions

View File

@@ -22,7 +22,7 @@ else:
pyfalog.debug("Saveddata connection string: {0}", saveddata_connectionstring)
settings = {
"setting1": True
"useStaticAdaptiveArmorHardener": False
}
# Autodetect path, only change if the autodetection bugs out.

View File

@@ -30,6 +30,7 @@ from eos.saveddata.targetResists import TargetResists
from eos.saveddata.character import Character
from eos.saveddata.implantSet import ImplantSet
from eos.saveddata.fit import Fit
from eos.saveddata.module import Module
from eos.saveddata.miscData import MiscData
from eos.saveddata.override import Override
@@ -241,22 +242,17 @@ def getFitsWithShip(shipID, ownerID=None, where=None, eager=None):
return fits
def getBoosterFits(ownerID=None, where=None, eager=None):
def getFitsWithModules(typeIDs, eager=None):
"""
Get all the fits that are flagged as a boosting ship
If no user is passed, do this for all users.
Get all the fits that have typeIDs fitted to them
"""
if ownerID is not None and not isinstance(ownerID, int):
raise TypeError("OwnerID must be integer")
filter = Fit.booster == 1
if ownerID is not None:
filter = and_(filter, Fit.ownerID == ownerID)
if not hasattr(typeIDs, "__iter__"):
typeIDs = (typeIDs,)
filter = processWhere(filter, where)
eager = processEager(eager)
with sd_lock:
fits = removeInvalid(saveddata_session.query(Fit).options(*eager).filter(filter).all())
fits = removeInvalid(saveddata_session.query(Fit).join(Module).options(*eager).filter(Module.itemID.in_(typeIDs)).all())
return fits

View File

@@ -3,6 +3,7 @@
# Used by:
# Module: Reactive Armor Hardener
from logbook import Logger
import eos.config
pyfalog = Logger(__name__)
@@ -13,6 +14,12 @@ type = "active"
def handler(fit, module, context):
damagePattern = fit.damagePattern
static_adaptive_behavior = eos.config.settings['useStaticAdaptiveArmorHardener']
if (damagePattern.emAmount == damagePattern.thermalAmount == damagePattern.kineticAmount == damagePattern.explosiveAmount) and static_adaptive_behavior:
pyfalog.debug("Setting adaptivearmorhardener resists to uniform profile.")
return
# Skip if there is no damage pattern. Example: projected ships or fleet boosters
if damagePattern:

View File

@@ -2,10 +2,8 @@
#
# Used by:
# Modules from group: Tractor Beam (4 of 4)
from eos.config import settings
type = "active"
def handler(fit, module, context):
print settings['setting1']
pass

View File

@@ -32,6 +32,8 @@ except ImportError:
from logbook import Logger
pyfalog = Logger(__name__)
# Keep a list of handlers that fail to import so we don't keep trying repeatedly.
badHandlers = []
class Effect(EqBase):
@@ -159,34 +161,51 @@ class Effect(EqBase):
Grab the handler, type and runTime from the effect code if it exists,
if it doesn't, set dummy values and add a dummy handler
"""
try:
self.__effectModule = effectModule = __import__('eos.effects.' + self.handlerName, fromlist=True)
self.__handler = getattr(effectModule, "handler", effectDummy)
self.__runTime = getattr(effectModule, "runTime", "normal")
self.__activeByDefault = getattr(effectModule, "activeByDefault", True)
t = getattr(effectModule, "type", None)
global badHandlers
t = t if isinstance(t, tuple) or t is None else (t,)
self.__type = t
except (ImportError) as e:
# Effect probably doesn't exist, so create a dummy effect and flag it with a warning.
# Skip if we've tried to import before and failed
if self.handlerName not in badHandlers:
try:
self.__effectModule = effectModule = __import__('eos.effects.' + self.handlerName, fromlist=True)
self.__handler = getattr(effectModule, "handler", effectDummy)
self.__runTime = getattr(effectModule, "runTime", "normal")
self.__activeByDefault = getattr(effectModule, "activeByDefault", True)
t = getattr(effectModule, "type", None)
t = t if isinstance(t, tuple) or t is None else (t,)
self.__type = t
except (ImportError) as e:
# Effect probably doesn't exist, so create a dummy effect and flag it with a warning.
self.__handler = effectDummy
self.__runTime = "normal"
self.__activeByDefault = True
self.__type = None
pyfalog.debug("ImportError generating handler: {0}", e)
badHandlers.append(self.handlerName)
except (AttributeError) as e:
# Effect probably exists but there is an issue with it. Turn it into a dummy effect so we can continue, but flag it with an error.
self.__handler = effectDummy
self.__runTime = "normal"
self.__activeByDefault = True
self.__type = None
pyfalog.error("AttributeError generating handler: {0}", e)
badHandlers.append(self.handlerName)
except Exception as e:
self.__handler = effectDummy
self.__runTime = "normal"
self.__activeByDefault = True
self.__type = None
pyfalog.critical("Exception generating handler:")
pyfalog.critical(e)
badHandlers.append(self.handlerName)
self.__generated = True
else:
# We've already failed on this one, just pass a dummy effect back
self.__handler = effectDummy
self.__runTime = "normal"
self.__activeByDefault = True
self.__type = None
pyfalog.debug("ImportError generating handler: {0}", e)
except (AttributeError) as e:
# Effect probably exists but there is an issue with it. Turn it into a dummy effect so we can continue, but flag it with an error.
self.__handler = effectDummy
self.__runTime = "normal"
self.__activeByDefault = True
self.__type = None
pyfalog.error("AttributeError generating handler: {0}", e)
except Exception as e:
pyfalog.critical("Exception generating handler:")
pyfalog.critical(e)
self.__generated = True
def getattr(self, key):
if not self.__generated: