Add STREAM_DELAY config key
authorOrakaro <nhatminh_179@hotmail.com>
Sun, 5 Oct 2014 07:24:46 +0000 (16:24 +0900)
committerOrakaro <nhatminh_179@hotmail.com>
Sun, 5 Oct 2014 07:24:46 +0000 (16:24 +0900)
docs/conf.py
docs/index.rst
rainbowstream/rainbow.py
setup.py

index dee298a535f76874dcfbdfee82097faf48e8a29f..a00eaa80aa495528416b964b1757ddbd98e0b35b 100644 (file)
@@ -48,9 +48,9 @@ copyright = u'2014, Vu Nhat Minh'
 # built documents.
 #
 # The short X.Y version.
-version = '1.1.5'
+version = '1.1.6'
 # The full version, including alpha/beta/rc tags.
-release = '1.1.5'
+release = '1.1.6'
 
 # The language for content autogenerated by Sphinx. Refer to documentation
 # for a list of supported languages.
index cb7da71d7d9239c1606145f2c57f9f687b099503..865af095d79198defd0ce39b8b212f877f3e3541 100644 (file)
@@ -359,6 +359,8 @@ You also can view or set a new value of every config key by ``config`` command (
 \r
 -  ``IMAGE_MAX_HEIGHT``: max height of image in '-iot'/'--image-on-term' mode.\r
 \r
+-  ``STREAM_DELAY``: seconds to wait before displaying another tweet, will drop all tweets while waiting. This value can be used to slow down the stream.\r
+\r
 -  ``USER_DOMAIN``: user URL of Twitter Streaming API.\r
 \r
 -  ``PUBLIC_DOMAIN``: public URL of Twitter Streaming API.\r
index ff654091bfb1187649025ad66aad7fd044c2a359..2b8a456571c676bbd477b1dee2d4a16ddf41171f 100644 (file)
@@ -2018,34 +2018,36 @@ def stream(domain, args, name='Rainbow Stream'):
                 StreamLock.release()
                 break
             elif tweet.get('text'):
-                if time.time() - last_tweet_time >= get_config("STREAM_DELAY"):
-                  last_tweet_time = time.time()
-                  # 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,
-                      fil=args.filter,
-                      ig=args.ignore,
-                  )
-                  # Current readline buffer
-                  current_buffer = readline.get_line_buffer().strip()
-                  # There is an unexpected behaviour in MacOSX readline + Python 2:
-                  # after completely delete a word after typing it,
-                  # somehow readline buffer still contains
-                  # the 1st character of that word
-                  if current_buffer and g['cmd'] != current_buffer:
-                      sys.stdout.write(
-                          g['decorated_name'](c['PREFIX']) + str2u(current_buffer))
-                      sys.stdout.flush()
-                  elif not c['HIDE_PROMPT']:
-                      sys.stdout.write(g['decorated_name'](c['PREFIX']))
-                      sys.stdout.flush()
+                # Slow down the stream by STREAM_DELAY config key
+                if time.time() - last_tweet_time < c['STREAM_DELAY']:
+                    continue
+                last_tweet_time = time.time()
+                # 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,
+                    fil=args.filter,
+                    ig=args.ignore,
+                )
+                # Current readline buffer
+                current_buffer = readline.get_line_buffer().strip()
+                # There is an unexpected behaviour in MacOSX readline + Python 2:
+                # after completely delete a word after typing it,
+                # somehow readline buffer still contains
+                # the 1st character of that word
+                if current_buffer and g['cmd'] != current_buffer:
+                    sys.stdout.write(
+                        g['decorated_name'](c['PREFIX']) + str2u(current_buffer))
+                    sys.stdout.flush()
+                elif not c['HIDE_PROMPT']:
+                    sys.stdout.write(g['decorated_name'](c['PREFIX']))
+                    sys.stdout.flush()
             elif tweet.get('direct_message'):
                 # Check the semaphore pause and lock (stream process only)
                 if g['pause']:
index c86e68c8b18dfc6e17ff6aff1b0e7132aa1d34a1..121ce5277d346113f29066d3ce62adb93d40fb16 100644 (file)
--- a/setup.py
+++ b/setup.py
@@ -3,7 +3,7 @@ import os
 import os.path
 
 # Bumped version
-version = '1.1.5'
+version = '1.1.6'
 
 # Require
 install_requires = [