From adb32ef4354c0278728ab4613bc2e133168cb2e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Thu, 22 Nov 2018 09:12:08 +0100 Subject: [PATCH] misc: don't crash if GraphicsMagick can't thumbnail a PDF (28044) --- wcs/qommon/misc.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/wcs/qommon/misc.py b/wcs/qommon/misc.py index fd676dc09..24c537b50 100644 --- a/wcs/qommon/misc.py +++ b/wcs/qommon/misc.py @@ -573,8 +573,11 @@ def get_thumbnail(filepath, content_type=None): raise ThumbnailError() if content_type == 'application/pdf': - fp = StringIO(subprocess.check_output( - ['gm', 'convert', '-geometry', '500x', filepath, 'png:-'])) + try: + fp = StringIO(subprocess.check_output( + ['gm', 'convert', '-geometry', '500x', filepath, 'png:-'])) + except subprocess.CalledProcessError: + raise ThumbnailError() else: fp = open(filepath) -- 2.19.1