[Kimchi-devel] [PATCH] Github #745: WoK: improve error message when importing plug-ins

Chandra Shehkhar Reddy Potula chandra at linux.vnet.ibm.com
Fri Oct 30 06:42:31 UTC 2015


Good and required one.

Reviewed-by: Chandra Shekhar Reddy Potula <chandra at linux.vnet.ibm.com>

On 10/30/2015 02:18 AM, dhbarboza82 at gmail.com wrote:
> From: Daniel Henrique Barboza <dhbarboza82 at gmail.com>
>
> Error messages in WoK boot-up process weren't being forwarded
> to the user, making it harder to detect the cause of the
> failure.
>
> Signed-off-by: Daniel Henrique Barboza <dhbarboza82 at gmail.com>
> ---
>   src/wok/server.py | 17 ++++++++++-------
>   src/wok/utils.py  |  7 +++++--
>   2 files changed, 15 insertions(+), 9 deletions(-)
>
> diff --git a/src/wok/server.py b/src/wok/server.py
> index c6f12dd..59ecdc0 100644
> --- a/src/wok/server.py
> +++ b/src/wok/server.py
> @@ -158,9 +158,11 @@ class Server(object):
>
>               try:
>                   plugin_app = import_class(plugin_class)(options)
> -            except ImportError:
> -                cherrypy.log.error_log.error("Failed to import plugin %s" %
> -                                             plugin_class)
> +            except ImportError, e:
> +                cherrypy.log.error_log.error(
> +                    "Failed to import plugin %s, "
> +                    "error: %s" % (plugin_class, e.message)
> +                )
>                   continue
>
>               # dynamically extend plugin config with custom data, if provided
> @@ -173,10 +175,11 @@ class Server(object):
>                   try:
>                       authed_apis = import_class(('plugins.%s.%s' %
>                                                   (plugin_name, extra_auth)))
> -                except ImportError:
> -                    cherrypy.log.error_log.error("Failed to import subnodes "
> -                                                 "for plugin %s" %
> -                                                 plugin_class)
> +                except ImportError, e:
> +                    cherrypy.log.error_log.error(
> +                        "Failed to import subnodes for plugin %s, "
> +                        "error: %s" % (plugin_class, e.message)
> +                    )
>                       continue
>
>                   urlSubNodes = {}
> diff --git a/src/wok/utils.py b/src/wok/utils.py
> index ccc8534..74c521f 100644
> --- a/src/wok/utils.py
> +++ b/src/wok/utils.py
> @@ -114,8 +114,11 @@ def import_class(class_path):
>       try:
>           mod = import_module(module_name, class_name)
>           return getattr(mod, class_name)
> -    except (ImportError, AttributeError):
> -        raise ImportError('Class %s can not be imported' % class_path)
> +    except (ImportError, AttributeError), e:
> +        raise ImportError(
> +            'Class %s can not be imported, '
> +            'error: %s' % (class_path, e.message)
> +        )
>
>
>   def import_module(module_name, class_name=''):




More information about the Kimchi-devel mailing list