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/Children.py
src/plugins/gramplet/DescendGramplet.py src/plugins/gramplet/DescendGramplet.py
src/plugins/gramplet/Events.py src/plugins/gramplet/Events.py
src/plugins/gramplet/Exif.py
src/plugins/gramplet/FanChartGramplet.py src/plugins/gramplet/FanChartGramplet.py
src/plugins/gramplet/FaqGramplet.py src/plugins/gramplet/FaqGramplet.py
src/plugins/gramplet/GivenNameGramplet.py src/plugins/gramplet/GivenNameGramplet.py
src/plugins/gramplet/gramplet.gpr.py src/plugins/gramplet/gramplet.gpr.py
src/plugins/gramplet/MetadataViewer.py
src/plugins/gramplet/Notes.py src/plugins/gramplet/Notes.py
src/plugins/gramplet/PedigreeGramplet.py src/plugins/gramplet/PedigreeGramplet.py
src/plugins/gramplet/PersonDetails.py src/plugins/gramplet/PersonDetails.py

View File

@ -191,6 +191,16 @@ def show_settings():
except ImportError: except ImportError:
cairover_str = 'not found' 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 import config
usebsddb3 = config.get('preferences.use-bsddb3') usebsddb3 = config.get('preferences.use-bsddb3')
try: try:
@ -256,6 +266,7 @@ def show_settings():
print ' bsddb : %s' % bsddb_str print ' bsddb : %s' % bsddb_str
print ' bsddb.db : %s' % bsddb_db_str print ' bsddb.db : %s' % bsddb_db_str
print ' cairo : %s' % cairover_str print ' cairo : %s' % cairover_str
print ' pyexiv2 : %s' % pyexiv2_str
print ' o.s. : %s' % operating_system print ' o.s. : %s' % operating_system
if kernel: if kernel:
print ' kernel : %s' % kernel print ' kernel : %s' % kernel

View File

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

View File

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

View File

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

View File

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

View File

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