Merge pull request #71 from polarkac/better_errors
[rainbowstream.git] / rainbowstream / rainbow.py
index 2b8a456571c676bbd477b1dee2d4a16ddf41171f..2d1be923b83181ae88199ab3a53dd46f0dadfc40 100644 (file)
@@ -27,6 +27,7 @@ from .interactive import *
 from .c_image import *
 from .py3patch import *
 from .emoji import *
+from .util import printTwitterErrors
 
 # Global values
 g = {}
@@ -178,6 +179,11 @@ def upgrade_center():
             notice += light_magenta('You should upgrade with ')
             notice += light_green('pip install -U rainbowstream')
             printNicely(notice)
+        else:
+            notice = light_yellow('You are running latest version (')
+            notice += light_green(current)
+            notice += light_yellow(')')
+            printNicely(notice)
     except:
         pass
 
@@ -1660,6 +1666,7 @@ def help():
     usage += s * 2 + light_green('p') + ' will pause the stream.\n'
     usage += s * 2 + light_green('r') + ' will unpause the stream.\n'
     usage += s * 2 + light_green('c') + ' will clear the screen.\n'
+    usage += s * 2 + light_green('v') + ' will show version info.\n'
     usage += s * 2 + light_green('q') + ' will quit.\n'
     # End
     usage += '\n'
@@ -1778,7 +1785,8 @@ cmdset = [
     'p',
     'r',
     'c',
-    'q'
+    'v',
+    'q',
 ]
 
 # Handle function set
@@ -1824,7 +1832,8 @@ funcset = [
     pause,
     replay,
     clear,
-    quit
+    upgrade_center,
+    quit,
 ]
 
 
@@ -1902,6 +1911,7 @@ def listen():
             [],  # pause
             [],  # reconnect
             [],  # clear
+            [],  # version
             [],  # quit
         ]
     ))
@@ -2058,10 +2068,11 @@ def stream(domain, args, name='Rainbow Stream'):
             elif tweet.get('event'):
                 c['events'].append(tweet)
                 print_event(tweet)
-    except TwitterHTTPError:
+    except TwitterHTTPError as e:
         printNicely('')
         printNicely(
             magenta("We have maximum connection problem with twitter'stream API right now :("))
+        printTwitterErrors(e)
 
 
 def fly():
@@ -2074,10 +2085,11 @@ def fly():
         proxy_connect(args)
         init(args)
     # Twitter API connection problem
-    except TwitterHTTPError:
+    except TwitterHTTPError as e:
         printNicely('')
         printNicely(
             magenta("We have connection problem with twitter'stream API right now :("))
+        printTwitterErrors(e)
         printNicely(magenta("Let's try again later."))
         save_history()
         sys.exit()