iot support Python 3
authorvunhat_minh <vunhat_minh@dwango.co.jp>
Fri, 11 Jul 2014 06:30:16 +0000 (15:30 +0900)
committervunhat_minh <vunhat_minh@dwango.co.jp>
Fri, 11 Jul 2014 06:30:16 +0000 (15:30 +0900)
rainbowstream/c_image.py
rainbowstream/draw.py
rainbowstream/py3patch.py

index 79226232f5a785314743e423c7fab46c58414a61..154552d2d7105c3e8f39e143400c32a7e9e62c5f 100644 (file)
@@ -40,9 +40,9 @@ def image_to_display(path,start=None,length=None):
     i = i.resize((width, height), Image.ANTIALIAS)
     height = min(height, c['IMAGE_MAX_HEIGHT'])
 
-    for y in xrange(height):
+    for y in range(height):
         sys.stdout.write(' ' * start)
-        for x in xrange(width):
+        for x in range(width):
             p = i.getpixel((x, y))
             r, g, b = p[:3]
             pixel_print(rgb2short(r, g, b))
index fa276f498da96dc7e925e24522dddd611a4e9c17..a0c7911805f2e0d459c49a6de8c658bd1eb9e9c1 100644 (file)
@@ -257,8 +257,8 @@ def draw(t, iot=False, keyword=None, fil=[], ig=[]):
         for mu in media_url:
             try:
                 response = requests.get(mu)
-                image_to_display(StringIO(response.content))
-            except:
+                image_to_display(BytesIO(response.content))
+            except Exception:
                 printNicely(red('Sorry, image link is broken'))
 
 
@@ -390,7 +390,7 @@ def show_profile(u, iot=False):
     if iot:
         try:
             response = requests.get(profile_image_url)
-            image_to_display(StringIO(response.content), 2, 20)
+            image_to_display(BytesIO(response.content), 2, 20)
         except:
             pass
     else:
index e1eec6e2ef70fc2827a622af7afc0689f75caa64..543b9a1462a27ef2fb5cb7100058159654b32ea4 100644 (file)
@@ -5,9 +5,9 @@ import sys
 
 # StringIO module
 try:
-    from StringIO import StringIO
+    from StringIO import StringIO, BytesIO
 except:
-    from io import StringIO
+    from io import StringIO, BytesIO
 
 # raw_input and map functiion behaviour
 if sys.version[0]=="3":