From 08cc6475af60221825c08a93ede131bc484443be Mon Sep 17 00:00:00 2001 From: Andriy Dzedolik Date: Fri, 16 Mar 2018 10:48:54 +0000 Subject: [PATCH 1/2] Fixed crash when IPTC reading fails --- sigal/gallery.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/sigal/gallery.py b/sigal/gallery.py index fffa37a..9941482 100644 --- a/sigal/gallery.py +++ b/sigal/gallery.py @@ -175,11 +175,15 @@ class Image(Media): # Nothing to do - we already have title and description return - iptc_data = get_iptc_data(self.src_path) - if not self.title and iptc_data.get('title'): - self.title = iptc_data['title'] - if not self.description and iptc_data.get('description'): - self.description = iptc_data['description'] + try: + iptc_data = get_iptc_data(self.src_path) + except Exception as e: + self.logger.warning(u'Could not read IPTC data from %s: %s', + self.src_path, e) + if not self.title and 'iptc_data' in locals() and iptc_data.get('title'): + self.title = iptc_data['title'] + if not self.description and 'iptc_data' in locals() and iptc_data.get('description'): + self.description = iptc_data['description'] @cached_property def raw_exif(self): From 802ebb752633a816f86c97dc9d31e8a3ad8c3ac4 Mon Sep 17 00:00:00 2001 From: Andriy Dzedolik Date: Mon, 19 Mar 2018 07:41:42 +0000 Subject: [PATCH 2/2] Updated IPTC fix with try-else block --- AUTHORS | 1 + sigal/gallery.py | 9 +++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/AUTHORS b/AUTHORS index 13916c8..e606930 100644 --- a/AUTHORS +++ b/AUTHORS @@ -6,6 +6,7 @@ alphabetical order): - Alexandre Chataignon (@xouillet) - Alexey Bazhin - Andreas Sieferlinger +- Andriy Dzedolik (@IrvinDitz) - Antoine Beaupré - Antoine Pitrou - Brent Bandelgar (@brentbb) diff --git a/sigal/gallery.py b/sigal/gallery.py index 9941482..35d74aa 100644 --- a/sigal/gallery.py +++ b/sigal/gallery.py @@ -180,10 +180,11 @@ class Image(Media): except Exception as e: self.logger.warning(u'Could not read IPTC data from %s: %s', self.src_path, e) - if not self.title and 'iptc_data' in locals() and iptc_data.get('title'): - self.title = iptc_data['title'] - if not self.description and 'iptc_data' in locals() and iptc_data.get('description'): - self.description = iptc_data['description'] + else: + if not self.title and iptc_data.get('title'): + self.title = iptc_data['title'] + if not self.description and iptc_data.get('description'): + self.description = iptc_data['description'] @cached_property def raw_exif(self):