From 47cee7034e3f8b4b5b0cf841b69b54e5b623e5e4 Mon Sep 17 00:00:00 2001 From: Orakaro Date: Sun, 21 Sep 2014 18:20:08 +0900 Subject: [PATCH] add reconn notice for Hangup --- docs/conf.py | 4 ++-- rainbowstream/rainbow.py | 30 +++++++++++++++++++++--------- setup.py | 2 +- 3 files changed, 24 insertions(+), 12 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index 12243a6..eafb44f 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.0.6' +version = '1.0.7' # The full version, including alpha/beta/rc tags. -release = '1.0.6' +release = '1.0.7' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/rainbowstream/rainbow.py b/rainbowstream/rainbow.py index d67be60..500c2db 100644 --- a/rainbowstream/rainbow.py +++ b/rainbowstream/rainbow.py @@ -1862,6 +1862,21 @@ def listen(): printNicely(red('OMG something is wrong with Twitter right now.')) +def reconn_notice(): + """ + Notice when Hangup or Timeout + """ + guide = light_magenta("You can use ") + \ + light_green("switch") + \ + light_magenta(" command to return to your stream.\n") + guide += light_magenta("Type ") + \ + light_green("h stream") + \ + light_magenta(" for more details.") + printNicely(guide) + sys.stdout.write(g['decorated_name'](c['PREFIX'])) + sys.stdout.flush() + + def stream(domain, args, name='Rainbow Stream'): """ Track the stream @@ -1905,24 +1920,21 @@ def stream(domain, args, name='Rainbow Stream'): if tweet is None: printNicely("-- None --") elif tweet is Timeout: + # Because the stream check for each 0.3s + # so we shouldn't output anything here if(g['stream_stop']): StreamLock.release() break elif tweet is HeartbeatTimeout: printNicely("-- Heartbeat Timeout --") - guide = light_magenta("You can use ") + \ - light_green("switch") + \ - light_magenta(" command to return to your stream.\n") - guide += light_magenta("Type ") + \ - light_green("h stream") + \ - light_magenta(" for more details.") - printNicely(guide) - sys.stdout.write(g['decorated_name'](c['PREFIX'])) - sys.stdout.flush() + reconn_notice() StreamLock.release() break elif tweet is Hangup: printNicely("-- Hangup --") + reconn_notice() + StreamLock.release() + break elif tweet.get('text'): # Check the semaphore pause and lock (stream process only) if g['pause']: diff --git a/setup.py b/setup.py index 07e5aa5..dec267a 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ import os import os.path # Bumped version -version = '1.0.6' +version = '1.0.7' # Require install_requires = [ -- 2.25.1