Sanity check to importing effect handler

Tweaks to opening effect files when in debug (support for OS X and Linux)
This commit is contained in:
blitzmann
2015-02-03 14:06:10 -05:00
parent 36a3ac70b6
commit c861adc5ed
2 changed files with 22 additions and 3 deletions

View File

@@ -120,7 +120,12 @@ class Effect(EqBase):
'''
try:
self.__effectModule = effectModule = __import__('eos.effects.' + self.handlerName, fromlist=True)
self.__handler = getattr(effectModule, "handler")
try:
self.__handler = getattr(effectModule, "handler")
except AttributeError:
print "effect {} exists, but no handler".format(self.handlerName)
raise
try:
self.__runTime = getattr(effectModule, "runTime") or "normal"
except AttributeError:
@@ -133,7 +138,7 @@ class Effect(EqBase):
t = t if isinstance(t, tuple) or t is None else (t,)
self.__type = t
except ImportError as e:
except (ImportError, AttributeError) as e:
self.__handler = effectDummy
self.__runTime = "normal"
self.__type = None

View File

@@ -523,10 +523,24 @@ class ItemEffects (wx.Panel):
self.Layout()
def OnClick(self, event):
"""
Debug use: open effect file with default application.
If effect file does not exist, create it
"""
import os
file = os.path.join(config.pyfaPath,"eos","effects","%s.py"%event.GetText().lower())
file = os.path.join(config.pyfaPath, "eos", "effects", "%s.py"%event.GetText().lower())
if not os.path.isfile(file):
open(file, 'a').close()
if 'wxMSW' in wx.PlatformInfo:
os.startfile(file)
elif 'wxMac' in wx.PlatformInfo:
os.system("open "+file)
else:
import subprocess
subprocess.call(["xdg-open", file])
###########################################################################