From 1b2617bf8e7b00d1b3c6b9cd2bbd22a01782ba79 Mon Sep 17 00:00:00 2001 From: GLolol Date: Sat, 1 Nov 2014 10:57:01 -0700 Subject: [PATCH] Owner: catch ImportError in a less confusing, friendlier way --- plugins/Owner/plugin.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/plugins/Owner/plugin.py b/plugins/Owner/plugin.py index d3e9e8a91..46f3cbe55 100644 --- a/plugins/Owner/plugin.py +++ b/plugins/Owner/plugin.py @@ -194,7 +194,16 @@ class Owner(callbacks.Plugin): s = 'Failed to load %s: no suitable database(%s).' % (name, e) log.warning(s) except ImportError as e: - s = 'Failed to load %s: import error (%s).' % (name, e) + e = str(e) + if e.endswith(name): + s = 'No plugin named %s exists.' % utils.str.dqrepr(name) + elif "No module named 'config'" in e: + s = ("Failed to load %s: This plugin is incompatible " + "with your current Python version. If this error is appearing " + "with stock Supybot plugins, remove the stock plugins directory " + "(usually ~/Limnoria/plugins) from 'config directories.plugins'." % name) + else: + s = 'Failed to load %s: import error (%s).' % (name, e) log.warning(s) except Exception as e: log.exception('Failed to load %s:', name) @@ -418,6 +427,9 @@ class Owner(callbacks.Plugin): except ImportError as e: if str(e).endswith(name): irc.error('No plugin named %s exists.' % utils.str.dqrepr(name)) + elif "No module named 'config'" in str(e): + irc.error('This plugin is incompatible with your current Python ' + 'version. Try running 2to3 on it.') else: irc.error(str(e)) return