quote and pause bug fix
authorOrakaro <nhatminh_179@hotmail.com>
Sun, 24 Aug 2014 07:32:32 +0000 (16:32 +0900)
committerOrakaro <nhatminh_179@hotmail.com>
Sun, 24 Aug 2014 07:32:32 +0000 (16:32 +0900)
docs/conf.py
rainbowstream/draw.py
rainbowstream/rainbow.py
screenshot/themes/Monokai.png
screenshot/themes/Solarized.png
screenshot/themes/TomorrowNight.png
screenshot/themes/larapaste.png
setup.py

index f2197653de44b7bb8f3149e938c161ebb2712264..ece453cd528618f02f2b1b8e6b2901c32462aa2b 100644 (file)
@@ -48,9 +48,9 @@ copyright = u'2014, Vu Nhat Minh'
 # built documents.
 #
 # The short X.Y version.
-version = '0.8.5'
+version = '0.8.6'
 # The full version, including alpha/beta/rc tags.
-release = '0.8.5'
+release = '0.8.6'
 
 # The language for content autogenerated by Sphinx. Refer to documentation
 # for a list of supported languages.
index 4fbe82723f46861c422dafb28d7ab3cb4abb7bf8..bfa3e2c7fa69461fe5502cdcb33f51a6b43a93cc 100644 (file)
@@ -144,18 +144,10 @@ def color_func(func_name):
     return globals()[func_name]
 
 
-def draw(t, keyword=None, humanize=True, check_semaphore=False, fil=[], ig=[]):
+def draw(t, keyword=None, humanize=True, fil=[], ig=[]):
     """
     Draw the rainbow
     """
-
-    # Check the semaphore pause and lock (stream process only)
-    if check_semaphore:
-        if c['pause']:
-            return
-        while c['lock']:
-            time.sleep(0.5)
-
     # Check config
     check_config()
 
@@ -318,18 +310,10 @@ def draw(t, keyword=None, humanize=True, check_semaphore=False, fil=[], ig=[]):
                 printNicely(red('Sorry, image link is broken'))
 
 
-def print_message(m, check_semaphore=False):
+def print_message(m):
     """
     Print direct message
     """
-
-    # Check the semaphore pause and lock (stream process only)
-    if check_semaphore:
-        if c['pause']:
-            return
-        while c['lock']:
-            time.sleep(0.5)
-
     # Retrieve message
     sender_screen_name = '@' + m['sender_screen_name']
     sender_name = m['sender']['name']
@@ -574,31 +558,31 @@ def format_quote(tweet):
     except:
         pass
     # Highlight like a tweet
-    formater = formater.split()
-    formater = lmap(
+    notice = formater.split()
+    notice = lmap(
         lambda x: light_green(x)
         if x == '#comment'
         else x,
-        formater)
-    formater = lmap(
+        notice)
+    notice = lmap(
         lambda x: color_func(c['TWEET']['rt'])(x)
         if x == 'RT'
         else x,
-        formater)
-    formater = lmap(lambda x: cycle_color(x) if x[0] == '@' else x, formater)
-    formater = lmap(
+        notice)
+    notice = lmap(lambda x: cycle_color(x) if x[0] == '@' else x, notice)
+    notice = lmap(
         lambda x: color_func(c['TWEET']['link'])(x)
         if x[0:4] == 'http'
         else x,
-        formater)
-    formater = lmap(
+        notice)
+    notice = lmap(
         lambda x: color_func(c['TWEET']['hashtag'])(x)
         if x.startswith('#')
         else x,
-        formater)
-    formater = ' '.join(formater)
+        notice)
+    notice = ' '.join(notice)
     # Notice
-    notice = light_magenta('Quoting: "') + formater + light_magenta('"')
+    notice = light_magenta('Quoting: "') + notice + light_magenta('"')
     printNicely(notice)
     return formater
 
index c4979378e76bed6ac86d0ac9ad9e45d246bad54a..94b2e4b67f2454acd5d1cafefa90a43f7f18961f 100644 (file)
@@ -127,11 +127,11 @@ def init(args):
     files = os.listdir(os.path.dirname(__file__) + '/colorset')
     themes = [f.split('.')[0] for f in files if f.split('.')[-1] == 'json']
     g['themes'] = themes
+    g['pause'] = False
     # Startup cmd
     g['cmd'] = ''
     # Semaphore init
     c['lock'] = False
-    c['pause'] = False
     # Init tweet dict and message dict
     c['tweet_dict'] = []
     c['message_dict'] = []
@@ -1450,7 +1450,7 @@ def pause():
     """
     Pause stream display
     """
-    c['pause'] = True
+    g['pause'] = True
     printNicely(green('Stream is paused'))
 
 
@@ -1458,7 +1458,7 @@ def replay():
     """
     Replay stream
     """
-    c['pause'] = False
+    g['pause'] = False
     printNicely(green('Stream is running back now'))
 
 
@@ -1760,11 +1760,16 @@ def stream(domain, args, name='Rainbow Stream'):
             elif tweet is Hangup:
                 printNicely("-- Hangup --")
             elif tweet.get('text'):
+                # Check the semaphore pause and lock (stream process only)
+                if g['pause']:
+                    continue
+                while c['lock']:
+                    time.sleep(0.5)
+                # Draw the tweet
                 draw(
                     t=tweet,
                     keyword=args.track_keywords,
                     humanize=False,
-                    check_semaphore=True,
                     fil=args.filter,
                     ig=args.ignore,
                 )
@@ -1782,7 +1787,12 @@ def stream(domain, args, name='Rainbow Stream'):
                     sys.stdout.write(g['decorated_name'](c['PREFIX']))
                     sys.stdout.flush()
             elif tweet.get('direct_message'):
-                print_message(tweet['direct_message'], check_semaphore=True)
+                # Check the semaphore pause and lock (stream process only)
+                if g['pause']:
+                    continue
+                while c['lock']:
+                    time.sleep(0.5)
+                print_message(tweet['direct_message'])
     except TwitterHTTPError:
         printNicely('')
         printNicely(
index 0da6361d8deb47211e66c17ff43e8d50f2ca012f..9c56c2d1bd35caebbbe2df54d765770ab498bcc2 100644 (file)
Binary files a/screenshot/themes/Monokai.png and b/screenshot/themes/Monokai.png differ
index 50df993b6b2dade2c5d823ae420aa913f3f795b2..2237320f7193495a8d3bb40c8d9845016246bf98 100644 (file)
Binary files a/screenshot/themes/Solarized.png and b/screenshot/themes/Solarized.png differ
index 520c616a649ff5140cfbb4c3af147989fd4fff2e..d07631cf96165afd98c7923ef8d63a188d2472ec 100644 (file)
Binary files a/screenshot/themes/TomorrowNight.png and b/screenshot/themes/TomorrowNight.png differ
index 866c077753c080d67f7375ad011e735cc56f4401..376dee7954b7c2e872bfe0f4af0e56422a9477eb 100644 (file)
Binary files a/screenshot/themes/larapaste.png and b/screenshot/themes/larapaste.png differ
index 1bd609ed2cf8d440ad0115d60b206551586e7272..a4e6dbaf35e5c2dffa13dc8907c9ac0d6e9e4913 100644 (file)
--- a/setup.py
+++ b/setup.py
@@ -3,7 +3,7 @@ import os
 import os.path
 
 # Bumped version
-version = '0.8.5'
+version = '0.8.6'
 
 # Require
 install_requires = [