trivival refactoring
[rainbowstream.git] / rainbowstream / rainbow.py
index 284a6282971d54ca320c76968830f530b43f8e04..206f84d1aa694ef4e95e8a6ad8491eb3ab2daa67 100644 (file)
@@ -27,6 +27,7 @@ from .interactive import *
 from .c_image import *
 from .py3patch import *
 from .emoji import *
+from .util import *
 
 # Global values
 g = {}
@@ -179,7 +180,10 @@ def upgrade_center():
             notice += light_green('pip install -U rainbowstream')
             printNicely(notice)
         else:
-            printNicely(yellow('You are running latest ' + current + ' version.'))
+            notice = light_yellow('You are running latest version (')
+            notice += light_green(current)
+            notice += light_yellow(')')
+            printNicely(notice)
     except:
         pass
 
@@ -1662,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'
@@ -1780,8 +1785,8 @@ cmdset = [
     'p',
     'r',
     'c',
+    'v',
     'q',
-    'version',
 ]
 
 # Handle function set
@@ -1827,8 +1832,8 @@ funcset = [
     pause,
     replay,
     clear,
-    quit,
     upgrade_center,
+    quit,
 ]
 
 
@@ -1906,8 +1911,8 @@ def listen():
             [],  # pause
             [],  # reconnect
             [],  # clear
-            [],  # quit
             [],  # version
+            [],  # quit
         ]
     ))
     init_interactive_shell(d)
@@ -2063,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 :("))
+            magenta("We have connection problem with twitter'stream API right now :("))
+        detail_twitter_error(e)
 
 
 def fly():
@@ -2079,11 +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 :("))
-        printNicely(magenta("Let's try again later."))
+            magenta("We have connection problem with twitter'REST API right now :("))
+        detail_twitter_error(e)
         save_history()
         sys.exit()
     # Proxy connection problem