From 9766d81bb81fd6ce4e86e1c5eb8c260b143a535e Mon Sep 17 00:00:00 2001 From: John Ralls Date: Fri, 7 Mar 2014 16:20:24 -0800 Subject: [PATCH] Convert two common plugin errors from unhandled exceptions to warnings. Missing translation for the current primary locale. Import failure because of some missing dependency. Note that these handlers can be overridded in the module itself; this is just a fallback. (cherry picked from commit 80c58f46d3b7b845e8506b8df6f4935e4d2ab90a) --- gramps/gen/plug/_manager.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/gramps/gen/plug/_manager.py b/gramps/gen/plug/_manager.py index 398460b52..caa23fc61 100644 --- a/gramps/gen/plug/_manager.py +++ b/gramps/gen/plug/_manager.py @@ -41,6 +41,9 @@ from __future__ import print_function import os import sys import re +import logging +LOG = logging.getLogger('.' + __name__) +LOG.progagate = True from ..const import GRAMPS_LOCALE as glocale _ = glocale.translation.gettext @@ -250,7 +253,12 @@ class BasePluginManager(object): if pdata.fpath not in sys.path: if pdata.mod_name: sys.path.insert(0, pdata.fpath) - module = __import__(pdata.mod_name) + try: + module = __import__(pdata.mod_name) + except ValueError as err: + LOG.warning('Plugin error: %s', err) + except ImportError as err: + LOG.warning('Plugin error: %s', err) sys.path.pop(0) else: print("WARNING: module cannot be loaded")