From 6e8fb961beee1eac87c0d0953427793bd4bb34f0 Mon Sep 17 00:00:00 2001 From: vunhat_minh Date: Wed, 10 Sep 2014 12:03:29 +0900 Subject: [PATCH] upgrade center --- docs/conf.py | 4 ++-- rainbowstream/rainbow.py | 32 +++++++++++++++++++++++++------- setup.py | 2 +- 3 files changed, 28 insertions(+), 10 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index 9c380c8..dfa7d32 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.0' +version = '1.0.1' # The full version, including alpha/beta/rc tags. -release = '1.0.0' +release = '1.0.1' # 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 bc7d85a..9c88fc8 100644 --- a/rainbowstream/rainbow.py +++ b/rainbowstream/rainbow.py @@ -8,6 +8,7 @@ import threading import requests import webbrowser import traceback +import pkg_resources from twitter.stream import TwitterStream, Timeout, HeartbeatTimeout, Hangup from twitter.api import * @@ -52,11 +53,6 @@ def parse_arguments(): '-ig', '--ignore', help='Ignore specific screen_name.') - parser.add_argument( - '-dg', - '--debug', - action='store_true', - help='Run in debug mode.') parser.add_argument( '-iot', '--image-on-term', @@ -123,6 +119,26 @@ def debug_option(): g['traceback'].append(traceback.format_exc()) +def upgrade_center(): + """ + Check latest and notify to upgrade + """ + try: + current = pkg_resources.get_distribution("rainbowstream").version + url = 'https://raw.githubusercontent.com/DTVD/rainbowstream/master/setup.py' + readme = requests.get(url).content + latest = readme.split("version = \'")[1].split("\'")[0] + if current != latest: + notice = light_magenta('RainbowStream latest version is ') + notice += light_green(latest) + notice += light_magenta(' while your current version is ') + notice += light_yellow(current) + '\n' + notice += light_magenta('You should upgrade with "pip install -U rainbowstream".') + printNicely(notice) + except: + pass + + def init(args): """ Init function @@ -130,6 +146,8 @@ def init(args): # Handle Ctrl C ctrl_c_handler = lambda signum, frame: quit() signal.signal(signal.SIGINT, ctrl_c_handler) + # Upgrade notify + upgrade_center() # Get name t = Twitter(auth=authen()) credential = t.account.verify_credentials() @@ -153,8 +171,8 @@ def init(args): g['events'] = [] # Startup cmd g['cmd'] = '' - # Debug option - g['debug'] = args.debug + # Debug option default = True + g['debug'] = True g['traceback'] = [] # Retweet of mine events c['events'] = [] diff --git a/setup.py b/setup.py index ee87291..ecadbcd 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ import os import os.path # Bumped version -version = '1.0.0' +version = '1.0.1' # Require install_requires = [ -- 2.25.1