Merge branch 'development' into feature/commandmenu

This commit is contained in:
Ryan Holmes
2017-03-26 14:43:12 -04:00
committed by GitHub
13 changed files with 115 additions and 42 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

@@ -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.warning("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: