diff --git a/doc/changelog.txt b/doc/changelog.txt index d4e9dfca..dc23b3c7 100644 --- a/doc/changelog.txt +++ b/doc/changelog.txt @@ -9,6 +9,9 @@ Fixes: - checking: Properly detect case where IPv6 is not supported. Closes: SF bug #3167249 +Changes: +- gui: Detect local or development versions in update check. + 6.2 "Despicable Me" (released 6.1.2011) diff --git a/linkcheck/gui/updater.py b/linkcheck/gui/updater.py index 66f60d9b..bb3586ec 100644 --- a/linkcheck/gui/updater.py +++ b/linkcheck/gui/updater.py @@ -54,12 +54,17 @@ class UpdateDialog (QtGui.QMessageBox): '%(app)s is installed.') attrs = dict(app=configuration.App) else: - # display update link version, url = value - text = _('A new version %(version)s of %(app)s is ' - 'available for download.') + if url is None: + # current version is newer than online version + text = _('Detected local or development version %(currentversion)s. ' + 'Available version of %(app)s is %(version)s.') + else: + # display update link + text = _('A new version %(version)s of %(app)s is ' + 'available for download.') attrs = dict(version=version, app=configuration.AppName, - url=url) + url=url, currentversion=configuration.Version) else: # value is an error message or None if UpdateThread has been # terminated diff --git a/linkcheck/updater.py b/linkcheck/updater.py index de47029f..144465eb 100644 --- a/linkcheck/updater.py +++ b/linkcheck/updater.py @@ -19,7 +19,7 @@ Function to check for updates. """ import os -from .configuration import Version +from .configuration import Version as CurrentVersion from .url import get_content from distutils.version import StrictVersion @@ -34,19 +34,27 @@ else: def check_update (): - """Return new version and URL, None if there is no update, or - an error message if there was an error.""" - version, value = get_current_version() + """Return the following values: + (False, errmsg) - online version could not be determined + (True, None) - user has newest version + (True, (version, url string)) - update available + (True, (version, None)) - current version is newer than online version + """ + version, value = get_online_version() if version is None: # value is an error message return False, value + if version == CurrentVersion: + # user has newest version + return True, None if is_newer_version(version): # value is an URL linking to the update package return True, (version, value) - return True, None + # user is running a local or development version + return True, (version, None) -def get_current_version (): +def get_online_version (): """Download update info and parse it.""" info, content = get_content(UPDATE_URL) if info is None: @@ -63,4 +71,4 @@ def get_current_version (): def is_newer_version (version): """Check if given version is newer than current version.""" - return StrictVersion(version) > StrictVersion(Version) + return StrictVersion(version) > StrictVersion(CurrentVersion) diff --git a/tests/test_updater.py b/tests/test_updater.py index a5f6e0f0..559bfe5b 100644 --- a/tests/test_updater.py +++ b/tests/test_updater.py @@ -28,9 +28,14 @@ class TestUpdater (unittest.TestCase): @need_network def test_updater (self): - res, url = linkcheck.updater.check_update() + res, value = linkcheck.updater.check_update() self.assertTrue(type(res) == bool) if res: - self.assertTrue(url is None or isinstance(url, basestring)) + self.assertTrue(value is None or isinstance(value, tuple)) + if isinstance(value, tuple): + self.assertEqual(len(value), 2) + version, url = value + self.assertTrue(isinstance(version, basestring)) + self.assertTrue(url is None or isinstance(url, basestring)) else: - self.assertTrue(isinstance(url, unicode)) + self.assertTrue(isinstance(value, unicode))