From 3a9a49d64cb4fdc602a12348a054140296fbf6cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20Cort=C3=A9z?= Date: Thu, 26 Feb 2015 10:26:46 -0600 Subject: [PATCH] Check for updates now works from the menu bar too --- src/controller/mainController.py | 8 ++++++-- src/update/update.py | 4 ++-- src/update/updater.py | 2 +- src/wxUI/view.py | 6 ++++-- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/controller/mainController.py b/src/controller/mainController.py index d9f53654..75e665cd 100644 --- a/src/controller/mainController.py +++ b/src/controller/mainController.py @@ -2,6 +2,7 @@ from wxUI import (view, dialogs, commonMessageDialogs) from twitter import utils from sessionmanager import manager +from update import updater import buffersController import messages import settings @@ -138,6 +139,7 @@ class Controller(object): widgetUtils.connect_event(self.view, widgetUtils.MENU, self.get_more_items, menuitem=self.view.load_previous_items) widgetUtils.connect_event(self.view, widgetUtils.MENU, self.clear_buffer, menuitem=self.view.clear) widgetUtils.connect_event(self.view, widgetUtils.MENU, self.remove_buffer, self.view.deleteTl) + widgetUtils.connect_event(self.view, widgetUtils.MENU, self.check_for_updates, self.view.check_for_updates) widgetUtils.connect_event(self.view.nb, widgetUtils.NOTEBOOK_PAGE_CHANGED, self.buffer_changed) def __init__(self): @@ -344,8 +346,10 @@ class Controller(object): def report_error(self): pass - def check_for_updates(self, show_msg=True): - pass + def check_for_updates(self, *args, **kwargs): + update = updater.do_update() + if update == False: + view.no_update_available() def show_details_for_user(self, user): pass diff --git a/src/update/update.py b/src/update/update.py index be65dc63..8fa8e70b 100644 --- a/src/update/update.py +++ b/src/update/update.py @@ -19,11 +19,11 @@ def perform_update(endpoint, current_version, app_name='', password=None, update available_update = find_update(endpoint, requests_session=requests_session) if not available_update: logger.debug("No update available") - return + return False available_version = available_update['current_version'] if not str(available_version) > str(current_version) or platform.system()+platform.architecture()[0][:2] not in available_update['downloads']: logger.debug("No update for this architecture") - return + return False available_description = available_update.get('description', None) update_url = available_update ['downloads'][platform.system()+platform.architecture()[0][:2]] logger.info("A new update is available. Version %s" % available_version) diff --git a/src/update/updater.py b/src/update/updater.py index 2ab7c539..d5635738 100644 --- a/src/update/updater.py +++ b/src/update/updater.py @@ -6,6 +6,6 @@ from wxUpdater import * def do_update(): # try: - update.perform_update(endpoint=application.update_url, current_version=application.version, app_name=application.name, update_available_callback=available_update_dialog, progress_callback=progress_callback, update_complete_callback=update_finished) + return update.perform_update(endpoint=application.update_url, current_version=application.version, app_name=application.name, update_available_callback=available_update_dialog, progress_callback=progress_callback, update_complete_callback=update_finished) # except: # pass \ No newline at end of file diff --git a/src/wxUI/view.py b/src/wxUI/view.py index ccdd4e86..227c1735 100644 --- a/src/wxUI/view.py +++ b/src/wxUI/view.py @@ -76,7 +76,6 @@ class mainFrame(wx.Frame): self.changelog = help.Append(wx.NewId(), _(u"&What's new in this version?")) self.changelog.Enable(False) self.check_for_updates = help.Append(wx.NewId(), _(u"&Check for updates")) - self.check_for_updates.Enable(False) self.reportError = help.Append(wx.NewId(), _(u"&Report an error")) self.reportError.Enable(False) self.visit_website = help.Append(-1, _(u"TW Blue &website")) @@ -172,4 +171,7 @@ class mainFrame(wx.Frame): wx.MessageDialog(self, address, _(u"Address"), wx.OK).ShowModal() def delete_buffer(self, pos): - self.nb.DeletePage(pos) \ No newline at end of file + self.nb.DeletePage(pos) + +def no_update_available(): + wx.MessageDialog(None, _(u"Your TW Blue version is up to date"), _(u"Update"), style=wx.OK).ShowModal()