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.
This commit is contained in:
parent
58d150ebc8
commit
80c58f46d3
@ -41,6 +41,9 @@ from __future__ import print_function
|
|||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import re
|
import re
|
||||||
|
import logging
|
||||||
|
LOG = logging.getLogger('.' + __name__)
|
||||||
|
LOG.progagate = True
|
||||||
from ..const import GRAMPS_LOCALE as glocale
|
from ..const import GRAMPS_LOCALE as glocale
|
||||||
_ = glocale.translation.gettext
|
_ = glocale.translation.gettext
|
||||||
|
|
||||||
@ -252,7 +255,12 @@ class BasePluginManager(object):
|
|||||||
if pdata.fpath not in sys.path:
|
if pdata.fpath not in sys.path:
|
||||||
if pdata.mod_name:
|
if pdata.mod_name:
|
||||||
sys.path.insert(0, pdata.fpath)
|
sys.path.insert(0, pdata.fpath)
|
||||||
|
try:
|
||||||
module = __import__(pdata.mod_name)
|
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)
|
sys.path.pop(0)
|
||||||
else:
|
else:
|
||||||
print("WARNING: module cannot be loaded")
|
print("WARNING: module cannot be loaded")
|
||||||
|
Loading…
Reference in New Issue
Block a user