mirror of
https://github.com/jlu5/PyLink.git
synced 2024-11-27 21:19:31 +01:00
main: Fix ImportError logging if a required library, and not the actual module is missing
The old message showed "the plugin/file could not be found" even if it's a library that couldn't be imported. "No module named X" is too broad to check for here!
This commit is contained in:
parent
c1d98838d7
commit
1e95f4b3df
12
main.py
12
main.py
@ -278,10 +278,10 @@ if __name__ == '__main__':
|
|||||||
pl = imp.load_source(plugin, moduleinfo[1])
|
pl = imp.load_source(plugin, moduleinfo[1])
|
||||||
utils.plugins.append(pl)
|
utils.plugins.append(pl)
|
||||||
except ImportError as e:
|
except ImportError as e:
|
||||||
if str(e).startswith('No module named'):
|
if str(e) == ('No module named %r' % plugin):
|
||||||
log.error('Failed to load plugin %r: the plugin could not be found.', plugin)
|
log.error('Failed to load plugin %r: The plugin could not be found.', plugin)
|
||||||
else:
|
else:
|
||||||
log.error('Failed to load plugin %r: import error %s', plugin, str(e))
|
log.error('Failed to load plugin %r: ImportError: %s', plugin, str(e))
|
||||||
else:
|
else:
|
||||||
if hasattr(pl, 'main'):
|
if hasattr(pl, 'main'):
|
||||||
log.debug('Calling main() function of plugin %r', pl)
|
log.debug('Calling main() function of plugin %r', pl)
|
||||||
@ -293,10 +293,10 @@ if __name__ == '__main__':
|
|||||||
moduleinfo = imp.find_module(protoname, protocols_folder)
|
moduleinfo = imp.find_module(protoname, protocols_folder)
|
||||||
proto = imp.load_source(protoname, moduleinfo[1])
|
proto = imp.load_source(protoname, moduleinfo[1])
|
||||||
except ImportError as e:
|
except ImportError as e:
|
||||||
if str(e).startswith('No module named'):
|
if str(e) == ('No module named %r' % protoname):
|
||||||
log.critical('Failed to load protocol module %r: the file could not be found.', protoname)
|
log.critical('Failed to load protocol module %r: The file could not be found.', protoname)
|
||||||
else:
|
else:
|
||||||
log.critical('Failed to load protocol module: import error %s', protoname, str(e))
|
log.critical('Failed to load protocol module: ImportError: %s', protoname, str(e))
|
||||||
sys.exit(2)
|
sys.exit(2)
|
||||||
else:
|
else:
|
||||||
utils.networkobjects[network] = Irc(network, proto, conf.conf)
|
utils.networkobjects[network] = Irc(network, proto, conf.conf)
|
||||||
|
Loading…
Reference in New Issue
Block a user