3
0
mirror of https://github.com/jlu5/PyLink.git synced 2024-11-27 21:19:31 +01:00

main.py: catch ImportError nicely

This commit is contained in:
James Lu 2015-06-07 17:04:23 -07:00
parent 36a93320d7
commit 38df372471

View File

@ -67,8 +67,14 @@ class Irc():
# Here, we override the module lookup and import the plugins
# dynamically depending on which were configured.
for plugin in to_load:
try:
moduleinfo = imp.find_module(plugin, plugins_folder)
self.loaded.append(imp.load_source(plugin, moduleinfo[1]))
except ImportError as e:
if str(e).startswith('No module named'):
print('Failed to load plugin %r: the plugin could not be found.' % plugin)
else:
print('Failed to load plugin %r: import error %s' (plugin, str(e)))
print("loaded plugins: %s" % self.loaded)
if __name__ == '__main__':