behave gracefully if no GExiv2 under Python3

svn: r21467
This commit is contained in:
Paul Franklin 2013-02-26 20:36:18 +00:00
parent 5e9837d484
commit e6034cde4b
2 changed files with 19 additions and 11 deletions

View File

@ -240,11 +240,17 @@ def show_settings():
osmgpsmap_str = 'not found' osmgpsmap_str = 'not found'
try: try:
from gi.repository import GExiv2 from gi import Repository
try: repository = Repository.get_default()
gexiv2_str = GExiv2._version if repository.enumerate_versions("GExiv2"):
except: # any failure to 'get' the version from gi.repository import GExiv2
gexiv2_str = 'unknown version' try:
gexiv2_str = GExiv2._version
except: # any failure to 'get' the version
gexiv2_str = 'unknown version'
else:
gexiv2_str = 'not found'
except ImportError: except ImportError:
gexiv2_str = 'not found' gexiv2_str = 'not found'

View File

@ -371,12 +371,14 @@ register(GRAMPLET,
) )
try: try:
from gi.repository import GExiv2 from gi import Repository
available = True repository = Repository.get_default()
except: if repository.enumerate_versions("GExiv2"):
import logging from gi.repository import GExiv2
logging.warning(_("WARNING: GExiv2 module not loaded. " available = True
"Image metadata functionality will not be available.")) else:
available = False
except ImportError:
available = False available = False
if available: if available: