From 07fbe2fec806ad71b57c54287b188484541decb3 Mon Sep 17 00:00:00 2001 From: Evelyn Date: Tue, 5 Sep 2017 10:03:38 +0100 Subject: [PATCH] Handle ImportError for module loading --- ModuleManager.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ModuleManager.py b/ModuleManager.py index 3de549d1..fdc2108d 100644 --- a/ModuleManager.py +++ b/ModuleManager.py @@ -59,7 +59,11 @@ class ModuleManager(object): def load_module(self, filename): name = self.module_name(filename) - module = self._load_module(filename) + try: + module = self._load_module(filename) + except ImportError as e: + sys.stderr.write("module '%s' not loaded: Could not resolve import.\n" % filename) + return if module: self.modules[module._name] = module if name in self.waiting_requirement: @@ -68,6 +72,7 @@ class ModuleManager(object): sys.stderr.write("module '%s' loaded.\n" % filename) else: sys.stderr.write("module '%s' not loaded.\n" % filename) + def load_modules(self): for filename in self.list_modules(): self.load_module(filename)