From b2e5f1ea0d56dc7906e37005b47ffea2e6bd9bb9 Mon Sep 17 00:00:00 2001 From: Benny Malengier Date: Thu, 3 Jan 2013 10:29:04 +0000 Subject: [PATCH] Recover gracefully from some errors in python3 svn: r20951 --- gramps/gen/display/name.py | 17 ++++++++++++++--- gramps/grampsapp.py | 10 ++++++++++ gramps/gui/grampsgui.py | 9 ++++++++- 3 files changed, 32 insertions(+), 4 deletions(-) diff --git a/gramps/gen/display/name.py b/gramps/gen/display/name.py index 13ffa0de7..004e315e4 100644 --- a/gramps/gen/display/name.py +++ b/gramps/gen/display/name.py @@ -55,6 +55,8 @@ Specific symbols for parts of a name are defined: #------------------------------------------------------------------------- from ..ggettext import sgettext as _ import re +import logging +LOG = logging.getLogger(".gramps.gen") #------------------------------------------------------------------------- # @@ -1047,8 +1049,17 @@ def fn(%s): else: return p + str + s return cleanup_name("%s" %% (%s))""" % (args, new_fmt, ",".join(param)) - exec(s) - - return locals()['fn'] + try: + exec(s) + return locals()['fn'] + except: + LOG.error("\n" + 'Wrong name format string %s' % new_fmt + +"\n" + ("ERROR, Edit Name format in Preferences->Display to correct") + +"\n" + _('Wrong name format string %s') % new_fmt + +"\n" + ("ERROR, Edit Name format in Preferences->Display to correct") + ) + def errfn(*arg): + return _("ERROR, Edit Name format in Preferences") + return errfn displayer = NameDisplay() diff --git a/gramps/grampsapp.py b/gramps/grampsapp.py index 7ac4981b8..ac91e6122 100644 --- a/gramps/grampsapp.py +++ b/gramps/grampsapp.py @@ -187,6 +187,16 @@ if not sys.version_info >= MIN_PYTHON_VERSION : 'v3': MIN_PYTHON_VERSION[2]}) sys.exit(1) +if sys.version_info[0] >= 3: + #check if bsddb3 is installed + try: + import bsddb3 + except ImportError: + logging.warning(_("\nYou don't have the python bsddb3 package installed." + " This package is needed to start Gramps.\n\n" + "Gramps will terminate now.")) + sys.exit(1) + #------------------------------------------------------------------------- # # gramps libraries diff --git a/gramps/gui/grampsgui.py b/gramps/gui/grampsgui.py index 01204a5e6..4c75d3326 100644 --- a/gramps/gui/grampsgui.py +++ b/gramps/gui/grampsgui.py @@ -51,7 +51,14 @@ except (ImportError, ValueError): "pygobject version 3.3.2 or later.\n\n" "Gramps will terminate now."))) sys.exit(0) - + +try: + import cairo +except ImportError: + print((_("\ncairo python support not installed. Install cairo for your " + "version of python\n\n" + "Gramps will terminate now."))) + sys.exit(0) #------------------------------------------------------------------------- # # Miscellaneous initialization