From: GreenZapdos Date: Sun, 5 Oct 2014 05:40:58 +0000 (-0600) Subject: Added STREAM_DELAY X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=e53e2c70918f55e31a86ce11064010cee39cfceb;p=rainbowstream.git Added STREAM_DELAY --- diff --git a/rainbowstream/colorset/config b/rainbowstream/colorset/config index 2d0b36e..31e6294 100644 --- a/rainbowstream/colorset/config +++ b/rainbowstream/colorset/config @@ -45,6 +45,8 @@ "IMAGE_SHIFT" : 2, // Image max height "IMAGE_MAX_HEIGHT" : 90, + // Seconds to wait before displaying another tweet, will drop all tweets while waiting. + "STREAM_DELAY" : 0, // Stream config "USER_DOMAIN" : "userstream.twitter.com", "PUBLIC_DOMAIN" : "stream.twitter.com", diff --git a/rainbowstream/rainbow.py b/rainbowstream/rainbow.py index 06bdd54..ff65409 100644 --- a/rainbowstream/rainbow.py +++ b/rainbowstream/rainbow.py @@ -1997,6 +1997,7 @@ def stream(domain, args, name='Rainbow Stream'): # Block new stream until other one exits StreamLock.acquire() g['stream_stop'] = False + last_tweet_time = time.time() for tweet in tweet_iter: if tweet is None: printNicely("-- None --") @@ -2017,32 +2018,34 @@ def stream(domain, args, name='Rainbow Stream'): StreamLock.release() break 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, - 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() + 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() elif tweet.get('direct_message'): # Check the semaphore pause and lock (stream process only) if g['pause']: