From 322b858fd0bda5982263da97a31887398b2b2a12 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Stefan=20K=C3=B6gl?= Date: Fri, 5 Jun 2015 21:30:09 +0000 Subject: [PATCH] [Feeds] open/write logo files in binary mode --- mygpo/data/feeddownloader.py | 2 +- mygpo/web/logo.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/mygpo/data/feeddownloader.py b/mygpo/data/feeddownloader.py index 9e8110b9..0605da24 100755 --- a/mygpo/data/feeddownloader.py +++ b/mygpo/data/feeddownloader.py @@ -333,7 +333,7 @@ def _save_podcast_logo(cover_art): logger.info('Logo %s', cover_art) # save new cover art - with open(filename, 'w') as fp: + with open(filename, 'wb') as fp: fp.write(urllib.request.urlopen(cover_art).read()) # get hash of new file diff --git a/mygpo/web/logo.py b/mygpo/web/logo.py index bc202d61..65aafd0e 100644 --- a/mygpo/web/logo.py +++ b/mygpo/web/logo.py @@ -92,7 +92,7 @@ class CoverArt(View): del draw resized = Image.composite(resized, background, resized) - sio = io.StringIO() + sio = io.BytesIO() try: resized.save(sio, 'JPEG', optimize=True, progression=True, @@ -140,7 +140,7 @@ class CoverArt(View): def send_file(self, filename): try: - f = open(filename) + f = open(filename, 'rb') except IOError: return HttpResponseNotFound() -- 2.11.4.GIT