From 4c025026dec3c67b7757261b14e9438b1e31d7b0 Mon Sep 17 00:00:00 2001 From: vunhat_minh Date: Mon, 28 Jul 2014 13:19:11 +0900 Subject: [PATCH] add color for hashtag and try catch for quit() in ctrl+c --- docs/conf.py | 4 ++-- rainbowstream/colorset/default.json | 1 + rainbowstream/colorset/larapaste.json | 1 + rainbowstream/colorset/monokai.json | 1 + rainbowstream/colorset/solarized.json | 1 + rainbowstream/colorset/tomorrow_night.json | 1 + rainbowstream/draw.py | 6 +++++- rainbowstream/rainbow.py | 16 +++++++++------- setup.py | 2 +- 9 files changed, 22 insertions(+), 11 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index 5afa34a..e5b64fe 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -51,9 +51,9 @@ copyright = u'2014, Vu Nhat Minh' # built documents. # # The short X.Y version. -version = '0.5.5' +version = '0.5.6' # The full version, including alpha/beta/rc tags. -release = '0.5.5' +release = '0.5.6' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/rainbowstream/colorset/default.json b/rainbowstream/colorset/default.json index 134891d..cfa251c 100644 --- a/rainbowstream/colorset/default.json +++ b/rainbowstream/colorset/default.json @@ -29,6 +29,7 @@ "favorited" : "light_green", "rt" : "grey", "link" : "light_cyan", + "hashtag" : "grey", "keyword" : "on_light_yellow" }, diff --git a/rainbowstream/colorset/larapaste.json b/rainbowstream/colorset/larapaste.json index 4763522..a89e095 100644 --- a/rainbowstream/colorset/larapaste.json +++ b/rainbowstream/colorset/larapaste.json @@ -29,6 +29,7 @@ "favorited" : 148, "rt" : 59, "link" : 148, + "hashtag" : 73, "keyword" : "on_light_green" }, diff --git a/rainbowstream/colorset/monokai.json b/rainbowstream/colorset/monokai.json index 27d7982..b0741c1 100644 --- a/rainbowstream/colorset/monokai.json +++ b/rainbowstream/colorset/monokai.json @@ -29,6 +29,7 @@ "favorited" : 50, "rt" : 179, "link" : 74, + "hashtag" : 198, "keyword" : "on_light_green" }, diff --git a/rainbowstream/colorset/solarized.json b/rainbowstream/colorset/solarized.json index b73cc70..efb1dd4 100644 --- a/rainbowstream/colorset/solarized.json +++ b/rainbowstream/colorset/solarized.json @@ -29,6 +29,7 @@ "favorited" : 64, "rt" : 66, "link" : 23, + "hashtag" : 64, "keyword" : "on_light_green" }, diff --git a/rainbowstream/colorset/tomorrow_night.json b/rainbowstream/colorset/tomorrow_night.json index c090274..57590b0 100644 --- a/rainbowstream/colorset/tomorrow_night.json +++ b/rainbowstream/colorset/tomorrow_night.json @@ -29,6 +29,7 @@ "favorited" : 54, "rt" : 145, "link" : 30, + "hashtag" : 103, "keyword" : "on_light_blue" }, diff --git a/rainbowstream/draw.py b/rainbowstream/draw.py index 218aa42..589d5f3 100644 --- a/rainbowstream/draw.py +++ b/rainbowstream/draw.py @@ -270,7 +270,11 @@ def draw(t, keyword=None, check_semaphore=False, fil=[], ig=[]): c['TWEET']['link'])(x) if x[ 0:4] == 'http' else x, tweet) - + # Highlight hashtag + tweet = lmap( + lambda x: color_func( + c['TWEET']['hashtag'])(x) if x.startswith('#') else x, + tweet) # Highlight keyword tweet = ' '.join(tweet) if keyword: diff --git a/rainbowstream/rainbow.py b/rainbowstream/rainbow.py index c721189..a9ee2ba 100644 --- a/rainbowstream/rainbow.py +++ b/rainbowstream/rainbow.py @@ -1471,10 +1471,13 @@ def quit(): """ Exit all """ - save_history() - os.system('rm -rf rainbow.db') - os.kill(g['stream_pid'], signal.SIGKILL) - printNicely(green('See you next time :)')) + try: + save_history() + os.system('rm -rf rainbow.db') + os.kill(g['stream_pid'], signal.SIGKILL) + printNicely(green('See you next time :)')) + except: + pass sys.exit() @@ -1711,9 +1714,8 @@ def fly(): except TwitterHTTPError: printNicely('') printNicely( - magenta("Something wrong with Twitter Oauth right now :(")) - printNicely( - magenta("Please delete ~/.rainbow_oauth and try again.")) + magenta("We have maximum connection problem with twitter'stream API right now :(")) + printNicely(magenta("Let's try again later.")) save_history() os.system('rm -rf rainbow.db') sys.exit() diff --git a/setup.py b/setup.py index 0c15d7a..f1b0a33 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ from setuptools import setup, find_packages import os, os.path, sys # Bumped version -version = '0.5.5' +version = '0.5.6' # Require install_requires = [ -- 2.25.1