Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Poirier <simpoir@gmail.com>2009-12-07 20:30:53 (GMT)
committer Simon Poirier <simpoir@gmail.com>2009-12-07 20:30:53 (GMT)
commit534a766fdc24b29777d982b66a71e56c906e4e31 (patch)
treebac1cf100fdb60590ffd229033b6b86fe230639e
parentf862db94a76fcb0d0f9e144b1af614e2c37bce9b (diff)
fancy traceback for exceptions in addons loading.
-rw-r--r--tutorius/addon.py29
1 files changed, 21 insertions, 8 deletions
diff --git a/tutorius/addon.py b/tutorius/addon.py
index 6e3d8b9..18d225a 100644
--- a/tutorius/addon.py
+++ b/tutorius/addon.py
@@ -35,6 +35,10 @@ __action__ = {
import os
import re
import logging
+import sys
+import traceback
+
+LOGGER = logging.getLogger('sugar.tutorius.addon')
PREFIX = __name__+"s"
PATH = re.sub("addon\\.py[c]$", "", __file__)+"addons"
@@ -48,14 +52,23 @@ def _reload_addons():
global _cache
_cache = {}
for addon in filter(lambda x: x.endswith("py"), os.listdir(PATH)):
- mod = __import__(PREFIX+'.'+re.sub("\\.py$", "", addon), {}, {}, [""])
- if hasattr(mod, "__action__"):
- _cache[mod.__action__['name']] = mod.__action__
- mod.__action__['type'] = TYPE_ACTION
- continue
- if hasattr(mod, "__event__"):
- _cache[mod.__event__['name']] = mod.__event__
- mod.__event__['type'] = TYPE_EVENT
+
+ try:
+ mod_name = PREFIX+'.'+re.sub("\\.py$", "", addon)
+ mod = __import__(mod_name, {}, {}, [""])
+ if hasattr(mod, "__action__"):
+ _cache[mod.__action__['name']] = mod.__action__
+ mod.__action__['type'] = TYPE_ACTION
+ continue
+ if hasattr(mod, "__event__"):
+ _cache[mod.__event__['name']] = mod.__event__
+ mod.__event__['type'] = TYPE_EVENT
+ except:
+ # fetch frame information to complement exception with traceback
+ type, value, tb = sys.exc_info()
+ formatted_tb = traceback.format_tb(tb)
+ LOGGER.error('Error loadin tutorius add-on [%s]:\n%s' % \
+ (mod_name, '\n'.join(formatted_tb)))
def create(name, *args, **kwargs):
global _cache