Recover gracefully from some errors in python3

svn: r20951
This commit is contained in:
Benny Malengier 2013-01-03 10:29:04 +00:00
parent cc878faf8f
commit b2e5f1ea0d
3 changed files with 32 additions and 4 deletions

View File

@ -55,6 +55,8 @@ Specific symbols for parts of a name are defined:
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
from ..ggettext import sgettext as _ from ..ggettext import sgettext as _
import re import re
import logging
LOG = logging.getLogger(".gramps.gen")
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
@ -1047,8 +1049,17 @@ def fn(%s):
else: else:
return p + str + s return p + str + s
return cleanup_name("%s" %% (%s))""" % (args, new_fmt, ",".join(param)) return cleanup_name("%s" %% (%s))""" % (args, new_fmt, ",".join(param))
exec(s) try:
exec(s)
return locals()['fn'] 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() displayer = NameDisplay()

View File

@ -187,6 +187,16 @@ if not sys.version_info >= MIN_PYTHON_VERSION :
'v3': MIN_PYTHON_VERSION[2]}) 'v3': MIN_PYTHON_VERSION[2]})
sys.exit(1) 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 # gramps libraries

View File

@ -51,7 +51,14 @@ except (ImportError, ValueError):
"pygobject version 3.3.2 or later.\n\n" "pygobject version 3.3.2 or later.\n\n"
"Gramps will terminate now."))) "Gramps will terminate now.")))
sys.exit(0) 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 # Miscellaneous initialization