diff --git a/doc/changelog.txt b/doc/changelog.txt index f78bac03..9c58598c 100644 --- a/doc/changelog.txt +++ b/doc/changelog.txt @@ -4,6 +4,9 @@ Changes: - checking: Parse PHP files recursively. - gui: Remove reset button from option dialog. +Features: +- gui: Add update check for newer versions of LinkChecker. + 6.1 "Christmas Vacation" (released 23.12.2010) diff --git a/linkcheck/gui/__init__.py b/linkcheck/gui/__init__.py index eb1bccd1..f3f1cd00 100644 --- a/linkcheck/gui/__init__.py +++ b/linkcheck/gui/__init__.py @@ -34,7 +34,7 @@ from .urlmodel import UrlItemModel from .urlsave import urlsave from .settings import Settings from .. import configuration, checker, director, add_intern_pattern, \ - strformat, fileutil + strformat, fileutil, updater from ..containers import enum from .. import url as urlutil from ..checker import httpheaders @@ -233,6 +233,34 @@ to improve %(appname)s even more! """Quit application.""" urlsave(self, self.config, self.model.urls) + @QtCore.pyqtSlot() + def on_actionCheckUpdates_triggered (self): + """Display update check result.""" + title = _('%(app)s update information') % dict(app=configuration.App) + # XXX check for update in background thread + result, value = updater.check_update() + if result: + dialog = QtGui.QMessageBox.information + if value is None: + # no update available: display info + text = _('Congratulations: you have the latest version ' + '%(app)s installed.') + attrs = dict(app=configuration.App) + else: + # display update link + version, url = 'hulla', 'bulla' + text = _('A new version %(version)s of %(app)s is ' + 'available for download.') + attrs = dict(version=version, app=configuration.AppName, + url=url) + else: + # value is an error message + dialog = QtGui.QMessageBox.warning + text = _('An error occured while checking for an ' + 'update of %(app)s: %(error)s.') + attrs = dict(error=value, app=configuration.AppName) + dialog(self, title, text % attrs) + def start (self): """Start a new check.""" if self.status == Status.idle: diff --git a/linkcheck/gui/linkchecker_ui_main.py b/linkcheck/gui/linkchecker_ui_main.py index 736418aa..b7f66958 100644 --- a/linkcheck/gui/linkchecker_ui_main.py +++ b/linkcheck/gui/linkchecker_ui_main.py @@ -2,7 +2,7 @@ # Form implementation generated from reading ui file 'ui/main.ui' # -# Created: Sat Dec 18 08:03:50 2010 +# Created: Tue Jan 4 19:19:45 2011 # by: PyQt4 UI code generator 4.7.3 # # WARNING! All changes made in this file will be lost! @@ -677,12 +677,15 @@ class Ui_MainWindow(object): icon8.addPixmap(QtGui.QPixmap(":/icons/exit.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.actionQuit.setIcon(icon8) self.actionQuit.setObjectName("actionQuit") + self.actionCheckUpdates = QtGui.QAction(MainWindow) + self.actionCheckUpdates.setObjectName("actionCheckUpdates") self.menuEdit.addAction(self.actionOptions) self.menuLinkChecka.addAction(self.actionSave) self.menuLinkChecka.addAction(self.actionQuit) self.menuHelp.addAction(self.actionAbout) self.menuHelp.addAction(self.actionHelp) self.menuHelp.addAction(self.actionDebug) + self.menuHelp.addAction(self.actionCheckUpdates) self.menubar.addAction(self.menuLinkChecka.menuAction()) self.menubar.addAction(self.menuEdit.menuAction()) self.menubar.addAction(self.menuHelp.menuAction()) @@ -746,6 +749,7 @@ class Ui_MainWindow(object): self.actionSave.setShortcut(_("Ctrl+S")) self.actionQuit.setText(_("Quit")) self.actionQuit.setShortcut(_("Ctrl+Q")) + self.actionCheckUpdates.setText(_("Check for updates")) from lineedit import LineEdit import linkchecker_rc diff --git a/linkcheck/gui/ui/main.ui b/linkcheck/gui/ui/main.ui index 85a9def2..3ac0a3d7 100644 --- a/linkcheck/gui/ui/main.ui +++ b/linkcheck/gui/ui/main.ui @@ -1292,6 +1292,7 @@ + @@ -1413,6 +1414,11 @@ Ctrl+Q + + + Check for updates + + diff --git a/linkcheck/updater.py b/linkcheck/updater.py index 0516b1a4..12351445 100644 --- a/linkcheck/updater.py +++ b/linkcheck/updater.py @@ -34,14 +34,15 @@ else: def check_update (): - """Return URL of new version, None if there is no update, or + """Return new version and URL, None if there is no update, or an error message if there was an error.""" - version, url = get_current_version() - print "XXX", version, url + version, value = get_current_version() if version is None: - return False, url + # value is an error message + return False, value if is_newer_version(version): - return True, url + # value is an URL linking to the update package + return True, (version, value) return True, None @@ -49,7 +50,7 @@ def get_current_version (): """Download update info and parse it.""" info, content = get_content(UPDATE_URL) if info is None: - None, _('Could not check for updates.') + None, _('could not download update information') version, url = None, None for line in content.splitlines(): if line.startswith(VERSION_TAG):