4849: Prevent errors in gramplets that depend on the pyexiv2 module when this module is not available

svn: r17186
This commit is contained in:
Nick Hall 2011-04-21 15:56:40 +00:00
parent 8c22cce7b2
commit bf23e340db
7 changed files with 44 additions and 25 deletions

View File

@ -266,11 +266,11 @@ src/plugins/gramplet/CalendarGramplet.py
src/plugins/gramplet/Children.py
src/plugins/gramplet/DescendGramplet.py
src/plugins/gramplet/Events.py
src/plugins/gramplet/Exif.py
src/plugins/gramplet/FanChartGramplet.py
src/plugins/gramplet/FaqGramplet.py
src/plugins/gramplet/GivenNameGramplet.py
src/plugins/gramplet/gramplet.gpr.py
src/plugins/gramplet/MetadataViewer.py
src/plugins/gramplet/Notes.py
src/plugins/gramplet/PedigreeGramplet.py
src/plugins/gramplet/PersonDetails.py

View File

@ -191,6 +191,16 @@ def show_settings():
except ImportError:
cairover_str = 'not found'
try:
import pyexiv2
try:
pyexiv2_str = '%d.%d.%d' % pyexiv2.version_info
except :# any failure to 'get' the version
pyexiv2_str = 'unknown version'
except ImportError:
pyexiv2_str = 'not found'
import config
usebsddb3 = config.get('preferences.use-bsddb3')
try:
@ -256,6 +266,7 @@ def show_settings():
print ' bsddb : %s' % bsddb_str
print ' bsddb.db : %s' % bsddb_db_str
print ' cairo : %s' % cairover_str
print ' pyexiv2 : %s' % pyexiv2_str
print ' o.s. : %s' % operating_system
if kernel:
print ' kernel : %s' % kernel

View File

@ -107,6 +107,7 @@ class GrampsBar(gtk.Notebook):
opts_list.sort(key=lambda opt: opt["page"])
for opts in opts_list:
if opts["name"] in AVAILABLE_GRAMPLETS():
all_opts = get_gramplet_opts(opts["name"], opts)
gramplet = make_requested_gramplet(TabGramplet, self, all_opts,
self.dbstate, self.uistate)
@ -126,7 +127,7 @@ class GrampsBar(gtk.Notebook):
Load the gramplets from the configuration file.
"""
retval = []
visible = False
visible = True
default_page = 0
filename = self.configfile
if filename and os.path.exists(filename):

View File

@ -16,7 +16,6 @@ pkgdata_PYTHON = \
Children.py \
DescendGramplet.py \
Events.py \
Exif.py \
FanChartGramplet.py \
FaqGramplet.py \
Filter.py \
@ -24,6 +23,7 @@ pkgdata_PYTHON = \
GivenNameGramplet.py \
gramplet.gpr.py \
MediaPreview.py \
MetadataViewer.py \
Notes.py \
PedigreeGramplet.py \
PersonDetails.py \

View File

@ -63,7 +63,7 @@ if not pyexiv2_req_install:
Min_VERSION_str, _DOWNLOAD_LINK, PrefVersion_str)
).encode(sys.getfilesystemencoding()) )
class Exif(Gramplet):
class MetadataViewer(Gramplet):
"""
Displays the exif tags of an image.
"""

View File

@ -77,19 +77,26 @@ register(GRAMPLET,
gramplet_title=_("Preview"),
)
try:
import pyexiv2
available = True
except:
print _("WARNING: pyexiv2 module not loaded. "
"Image metadata functionality will not be available.")
available = False
if available:
register(GRAMPLET,
id = "Exif Viewer Gramplet",
name = _("Exif Viewer Gramplet"),
description = _("Gramplet showing exif tags for a media object"),
id = "Metadata Viewer Gramplet",
name = _("Metadata Viewer Gramplet"),
description = _("Gramplet showing metadata for a media object"),
version = "1.0.0",
gramps_target_version = "3.4",
status = STABLE,
fname = "Exif.py",
fname = "MetadataViewer.py",
height = 200,
gramplet = 'Exif',
gramplet_title = _("Exif"),
authors = ["Rob G. Healey"],
authors_email = ["robhealey1@gmail.com"],
gramplet = 'MetadataViewer',
gramplet_title = _("Image Metadata"),
)
register(GRAMPLET,

View File

@ -425,8 +425,8 @@ class MediaView(ListView):
"""
return (("Media Filter Gramplet",),
("Media Preview Gramplet",
"Exif Viewer Gramplet",
"Media Sources Gramplet",
"Media Notes Gramplet",
"Media Attributes Gramplet",
"Metadata Viewer Gramplet",
"Media Backlinks Gramplet"))