Handle ImportError for module loading
This commit is contained in:
parent
5dcbfe588d
commit
07fbe2fec8
1 changed files with 6 additions and 1 deletions
|
@ -59,7 +59,11 @@ class ModuleManager(object):
|
||||||
|
|
||||||
def load_module(self, filename):
|
def load_module(self, filename):
|
||||||
name = self.module_name(filename)
|
name = self.module_name(filename)
|
||||||
|
try:
|
||||||
module = self._load_module(filename)
|
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:
|
if module:
|
||||||
self.modules[module._name] = module
|
self.modules[module._name] = module
|
||||||
if name in self.waiting_requirement:
|
if name in self.waiting_requirement:
|
||||||
|
@ -68,6 +72,7 @@ class ModuleManager(object):
|
||||||
sys.stderr.write("module '%s' loaded.\n" % filename)
|
sys.stderr.write("module '%s' loaded.\n" % filename)
|
||||||
else:
|
else:
|
||||||
sys.stderr.write("module '%s' not loaded.\n" % filename)
|
sys.stderr.write("module '%s' not loaded.\n" % filename)
|
||||||
|
|
||||||
def load_modules(self):
|
def load_modules(self):
|
||||||
for filename in self.list_modules():
|
for filename in self.list_modules():
|
||||||
self.load_module(filename)
|
self.load_module(filename)
|
||||||
|
|
Loading…
Reference in a new issue