From: Orakaro Date: Sun, 5 Oct 2014 07:24:46 +0000 (+0900) Subject: Add STREAM_DELAY config key X-Git-Url: https://vcs.fsf.org/?p=rainbowstream.git;a=commitdiff_plain;h=84b41f58f96ea5feb9c571984b60d734d9037e42;ds=inline Add STREAM_DELAY config key --- diff --git a/docs/conf.py b/docs/conf.py index dee298a..a00eaa8 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -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. diff --git a/docs/index.rst b/docs/index.rst index cb7da71..865af09 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -359,6 +359,8 @@ You also can view or set a new value of every config key by ``config`` command ( - ``IMAGE_MAX_HEIGHT``: max height of image in '-iot'/'--image-on-term' mode. +- ``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. + - ``USER_DOMAIN``: user URL of Twitter Streaming API. - ``PUBLIC_DOMAIN``: public URL of Twitter Streaming API. diff --git a/rainbowstream/rainbow.py b/rainbowstream/rainbow.py index ff65409..2b8a456 100644 --- a/rainbowstream/rainbow.py +++ b/rainbowstream/rainbow.py @@ -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']: diff --git a/setup.py b/setup.py index c86e68c..121ce52 100644 --- 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 = [