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:
parent
36a93320d7
commit
38df372471
10
main.py
10
main.py
@ -67,8 +67,14 @@ class Irc():
|
|||||||
# Here, we override the module lookup and import the plugins
|
# Here, we override the module lookup and import the plugins
|
||||||
# dynamically depending on which were configured.
|
# dynamically depending on which were configured.
|
||||||
for plugin in to_load:
|
for plugin in to_load:
|
||||||
moduleinfo = imp.find_module(plugin, plugins_folder)
|
try:
|
||||||
self.loaded.append(imp.load_source(plugin, moduleinfo[1]))
|
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)
|
print("loaded plugins: %s" % self.loaded)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
Loading…
Reference in New Issue
Block a user