Graceful handling of errors from rsvg-convert

This commit is contained in:
Kovid Goyal 2017-10-03 21:29:06 +05:30
parent 72626279c2
commit e56042c41a
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -124,11 +124,14 @@ def show(data, mode, width, height):
def convert_svg(path):
try:
return subprocess.check_output(['rsvg-convert', '-f', 'png', path])
with open(os.devnull, 'wb') as null:
return subprocess.check_output(['rsvg-convert', '-f', 'png', path], stderr=null)
except OSError:
raise SystemExit(
'Could not find the program rsvg-convert, needed to display svg files'
)
except subprocess.CalledProcessError:
raise OpenFailed(path, 'rsvg-convert could not process the image')
def process(path, mt):