From 17bc529db5669ed5c44a3b74b13d9671ed2243b1 Mon Sep 17 00:00:00 2001 From: vunhat_minh Date: Thu, 10 Jul 2014 20:03:18 +0900 Subject: [PATCH] fix image IOError --- rainbowstream/draw.py | 14 ++++++++++---- setup.py | 2 +- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/rainbowstream/draw.py b/rainbowstream/draw.py index faf57f9..57e7867 100644 --- a/rainbowstream/draw.py +++ b/rainbowstream/draw.py @@ -256,8 +256,11 @@ def draw(t, iot=False, keyword=None, fil=[], ig=[]): # Display Image if iot and media_url: for mu in media_url: - response = requests.get(mu) - image_to_display(StringIO(response.content)) + try: + response = requests.get(mu) + image_to_display(StringIO(response.content)) + except: + printNicely(red('Sorry, image link is broken')) def print_message(m): @@ -386,8 +389,11 @@ def show_profile(u, iot=False): printNicely('') printNicely(line1) if iot: - response = requests.get(profile_image_url) - image_to_display(StringIO(response.content), 2, 20) + try: + response = requests.get(profile_image_url) + image_to_display(StringIO(response.content), 2, 20) + except: + pass else: printNicely(line2) for line in [line3, line4, line5, line6]: diff --git a/setup.py b/setup.py index d55414a..af31317 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,6 @@ from setuptools import setup, find_packages -version = '0.2.6' +version = '0.2.7' install_requires = [ "python-dateutil", -- 2.25.1