From e6034cde4b1c82459c68fd3a25f268d0a55cbc2f Mon Sep 17 00:00:00 2001 From: Paul Franklin Date: Tue, 26 Feb 2013 20:36:18 +0000 Subject: [PATCH] behave gracefully if no GExiv2 under Python3 svn: r21467 --- gramps/grampsapp.py | 16 +++++++++++----- gramps/plugins/gramplet/gramplet.gpr.py | 14 ++++++++------ 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/gramps/grampsapp.py b/gramps/grampsapp.py index 4373103f0..81dd757d7 100644 --- a/gramps/grampsapp.py +++ b/gramps/grampsapp.py @@ -240,11 +240,17 @@ def show_settings(): osmgpsmap_str = 'not found' try: - from gi.repository import GExiv2 - try: - gexiv2_str = GExiv2._version - except: # any failure to 'get' the version - gexiv2_str = 'unknown version' + from gi import Repository + repository = Repository.get_default() + if repository.enumerate_versions("GExiv2"): + from gi.repository import GExiv2 + try: + gexiv2_str = GExiv2._version + except: # any failure to 'get' the version + gexiv2_str = 'unknown version' + else: + gexiv2_str = 'not found' + except ImportError: gexiv2_str = 'not found' diff --git a/gramps/plugins/gramplet/gramplet.gpr.py b/gramps/plugins/gramplet/gramplet.gpr.py index a11319ef0..bcfd565c8 100644 --- a/gramps/plugins/gramplet/gramplet.gpr.py +++ b/gramps/plugins/gramplet/gramplet.gpr.py @@ -371,12 +371,14 @@ register(GRAMPLET, ) try: - from gi.repository import GExiv2 - available = True -except: - import logging - logging.warning(_("WARNING: GExiv2 module not loaded. " - "Image metadata functionality will not be available.")) + from gi import Repository + repository = Repository.get_default() + if repository.enumerate_versions("GExiv2"): + from gi.repository import GExiv2 + available = True + else: + available = False +except ImportError: available = False if available: