From 5a26443681e0616bccd7fff01dc8cba0aab9e6e1 Mon Sep 17 00:00:00 2001 From: Arjan Schrijver Date: Mon, 7 Jan 2013 10:18:29 +0100 Subject: [PATCH 1/3] fixed bug #1095699 'check_dependencies.py fails on version numbers with letters' Fixes: https://launchpad.net/bugs/1095699 --- scripts/check_dependencies.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/scripts/check_dependencies.py b/scripts/check_dependencies.py index fef8fc2be..be15414b4 100755 --- a/scripts/check_dependencies.py +++ b/scripts/check_dependencies.py @@ -38,6 +38,7 @@ modules, simply run this script:: """ import os import sys +from distutils.version import LooseVersion is_win = sys.platform.startswith('win') @@ -89,15 +90,13 @@ OPTIONAL_MODULES = [ w = sys.stdout.write def check_vers(version, required, text): - if type(version) is str: - version = version.split('.') - version = map(int, version) - if type(required) is str: - required = required.split('.') - required = map(int, required) - w(' %s >= %s ... ' % (text, '.'.join(map(str, required)))) - if version >= required: - w('.'.join(map(str, version)) + os.linesep) + if type(version) is not str: + version = '.'.join(map(str, version)) + if type(required) is not str: + required = '.'.join(map(str, required)) + w(' %s >= %s ... ' % (text, required)) + if LooseVersion(version) >= LooseVersion(required): + w(version + os.linesep) return True else: w('FAIL' + os.linesep) From 6531224cecfe1a5f43453706ff6cec2c3f47f1e6 Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Tue, 8 Jan 2013 08:20:49 +0200 Subject: [PATCH 2/3] Fix an erroneous and unused import in a test. --- tests/functional/openlp_core_lib/test_lib.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/functional/openlp_core_lib/test_lib.py b/tests/functional/openlp_core_lib/test_lib.py index 7b3d64fd2..90e429b9a 100644 --- a/tests/functional/openlp_core_lib/test_lib.py +++ b/tests/functional/openlp_core_lib/test_lib.py @@ -3,7 +3,7 @@ Package to test the openlp.core.lib package. """ from unittest import TestCase -from mock import MagicMock, patch, call +from mock import MagicMock, patch from openlp.core.lib import str_to_bool, translate, check_directory_exists, get_text_file_string From f738037d19df81a50cb9d681bfa191f55923933f Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Tue, 8 Jan 2013 22:44:56 +0200 Subject: [PATCH 3/3] Change the way the version check works so that nightlies check a nightly file, dev releases a dev file, and stable releases a version file. --- openlp/.version | 2 +- openlp/core/utils/__init__.py | 20 ++++++++++++++++---- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/openlp/.version b/openlp/.version index cd5ac039d..d41002840 100644 --- a/openlp/.version +++ b/openlp/.version @@ -1 +1 @@ -2.0 +2.1.0-bzr2141 diff --git a/openlp/core/utils/__init__.py b/openlp/core/utils/__init__.py index 2a303e87d..b90ea4b86 100644 --- a/openlp/core/utils/__init__.py +++ b/openlp/core/utils/__init__.py @@ -29,12 +29,13 @@ """ The :mod:`openlp.core.utils` module provides the utility libraries for OpenLP. """ -from datetime import datetime +from datetime import datetime, timedelta from distutils.version import LooseVersion import logging import locale import os import re +from reportlab.graphics.charts.utils import seconds2str from subprocess import Popen, PIPE import sys import urllib2 @@ -277,20 +278,31 @@ def check_latest_version(current_version): ``current_version`` The current version of OpenLP. + + **Rules around versions and version files:** + + * If a version number has a build (i.e. -bzr1234), then it is a nightly. + * If a version number's minor version is an odd number, it is a development release. + * If a version number's minor version is an even number, it is a stable release. """ version_string = current_version[u'full'] # set to prod in the distribution config file. settings = Settings() settings.beginGroup(u'general') - last_test = settings.value(u'last version test', datetime.now().date()) + # This defaults to yesterday in order to force the update check to run when you've never run it before. + last_test = settings.value(u'last version test', datetime.now().date() - timedelta(days=1)) this_test = datetime.now().date() settings.setValue(u'last version test', this_test) settings.endGroup() if last_test != this_test: if current_version[u'build']: - req = urllib2.Request(u'http://www.openlp.org/files/dev_version.txt') + req = urllib2.Request(u'http://www.openlp.org/files/nightly_version.txt') else: - req = urllib2.Request(u'http://www.openlp.org/files/version.txt') + version_parts = current_version[u'version'].split(u'.') + if int(version_parts[1]) % 2 != 0: + req = urllib2.Request(u'http://www.openlp.org/files/dev_version.txt') + else: + req = urllib2.Request(u'http://www.openlp.org/files/version.txt') req.add_header(u'User-Agent', u'OpenLP/%s' % current_version[u'full']) remote_version = None try: