From e9260c3d6f7791d124bfbf657a66ecb5e3e16659 Mon Sep 17 00:00:00 2001 From: nicolargo Date: Mon, 10 Apr 2017 15:26:11 +0200 Subject: [PATCH] Improve error message as asked in issue #1078 --- glances/stats_client.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/glances/stats_client.py b/glances/stats_client.py index cf14acf8..1d6278cf 100644 --- a/glances/stats_client.py +++ b/glances/stats_client.py @@ -45,13 +45,18 @@ class GlancesStatsClient(GlancesStats): header = "glances_" for item in input_plugins: # Import the plugin - plugin = __import__(header + item) - # Add the plugin to the dictionary - # The key is the plugin name - # for example, the file glances_xxx.py - # generate self._plugins_list["xxx"] = ... - logger.debug("Server uses {} plugin".format(item)) - self._plugins[item] = plugin.Plugin(args=self.args) + try: + plugin = __import__(header + item) + except ImportError: + # Server plugin can not be imported from the client side + logger.error("Can not import {} plugin. Please upgrade your Glances client/server version.".format(item)) + else: + # Add the plugin to the dictionary + # The key is the plugin name + # for example, the file glances_xxx.py + # generate self._plugins_list["xxx"] = ... + logger.debug("Server uses {} plugin".format(item)) + self._plugins[item] = plugin.Plugin(args=self.args) # Restoring system path sys.path = sys_path