Use Python's version comparison, not Qt's

This commit is contained in:
Raoul Snyman 2024-03-06 15:58:22 +00:00
parent 0d3acc2e67
commit 5508bb683c
5 changed files with 9 additions and 7 deletions

View File

@ -31,7 +31,7 @@ install:
# Update pip # Update pip
- python -m pip install --upgrade pip - python -m pip install --upgrade pip
# Install generic dependencies from pypi. # Install generic dependencies from pypi.
- python -m pip install sqlalchemy alembic platformdirs chardet beautifulsoup4 lxml Mako mysql-connector-python pytest mock psycopg2-binary websockets waitress six requests QtAwesome PyQt5 PyQtWebEngine pymediainfo PyMuPDF QDarkStyle python-vlc flask-cors pytest-qt pyenchant pysword qrcode flask - python -m pip install sqlalchemy alembic platformdirs chardet beautifulsoup4 lxml Mako mysql-connector-python pytest mock psycopg2-binary websockets waitress six requests QtAwesome PyQt5 PyQtWebEngine pymediainfo PyMuPDF QDarkStyle python-vlc flask-cors pytest-qt pyenchant pysword qrcode flask packaging
# Install Windows only dependencies # Install Windows only dependencies
- cmd: python -m pip install pyodbc pypiwin32 - cmd: python -m pip install pyodbc pypiwin32
- cmd: choco install vlc %CHOCO_VLC_ARG% --no-progress --limit-output - cmd: choco install vlc %CHOCO_VLC_ARG% --no-progress --limit-output

View File

@ -27,6 +27,7 @@ import sys
from collections import OrderedDict from collections import OrderedDict
from datetime import date from datetime import date
from packaging.version import parse
from PyQt5 import QtCore from PyQt5 import QtCore
from openlp.core.common.applocation import AppLocation from openlp.core.common.applocation import AppLocation
@ -114,8 +115,7 @@ class VersionWorker(ThreadWorker):
retries += 1 retries += 1
else: else:
self.no_internet.emit() self.no_internet.emit()
if remote_version and (QtCore.QVersionNumber.fromString(remote_version) > if remote_version and (parse(remote_version) > parse(self.current_version['full'])):
QtCore.QVersionNumber.fromString(self.current_version['full'])):
self.new_version.emit(remote_version) self.new_version.emit(remote_version)
self.quit.emit() self.quit.emit()

View File

@ -95,6 +95,7 @@ MODULES = [
'pymediainfo', 'pymediainfo',
'vlc', 'vlc',
'qrcode', 'qrcode',
'packaging',
] ]

View File

@ -105,6 +105,7 @@ using a computer and a display/projector.""",
'flask-cors', 'flask-cors',
'lxml', 'lxml',
'Mako', 'Mako',
'packaging',
'platformdirs', 'platformdirs',
'PyICU', 'PyICU',
'pymediainfo >= 2.2', 'pymediainfo >= 2.2',

View File

@ -135,7 +135,7 @@ def test_worker_start_nightly_version(mock_get_web_page, mock_platform):
""" """
# GIVEN: A last check date, current version, and an instance of worker # GIVEN: A last check date, current version, and an instance of worker
last_check_date = '1970-01-01' last_check_date = '1970-01-01'
current_version = {'full': '2.1-bzr2345', 'version': '2.1', 'build': '2345'} current_version = {'full': '2.1.0+git2345', 'version': '2.1', 'build': '2345'}
mock_platform.system.return_value = 'Linux' mock_platform.system.return_value = 'Linux'
mock_platform.release.return_value = '4.12.0-1-amd64' mock_platform.release.return_value = '4.12.0-1-amd64'
mock_get_web_page.return_value = '2.4.6' mock_get_web_page.return_value = '2.4.6'
@ -148,7 +148,7 @@ def test_worker_start_nightly_version(mock_get_web_page, mock_platform):
# THEN: The check completes and the signal is emitted # THEN: The check completes and the signal is emitted
expected_download_url = 'https://get.openlp.org/versions/nightly_version.txt' expected_download_url = 'https://get.openlp.org/versions/nightly_version.txt'
expected_headers = {'User-Agent': 'OpenLP/2.1-bzr2345 Linux/4.12.0-1-amd64; '} expected_headers = {'User-Agent': 'OpenLP/2.1.0+git2345 Linux/4.12.0-1-amd64; '}
mock_get_web_page.assert_called_once_with(expected_download_url, headers=expected_headers) mock_get_web_page.assert_called_once_with(expected_download_url, headers=expected_headers)
mock_new_version.emit.assert_called_once_with('2.4.6') mock_new_version.emit.assert_called_once_with('2.4.6')
mock_quit.emit.assert_called_once_with() mock_quit.emit.assert_called_once_with()
@ -162,7 +162,7 @@ def test_worker_empty_response(mock_get_web_page, mock_platform):
""" """
# GIVEN: A last check date, current version, and an instance of worker # GIVEN: A last check date, current version, and an instance of worker
last_check_date = '1970-01-01' last_check_date = '1970-01-01'
current_version = {'full': '2.1-bzr2345', 'version': '2.1', 'build': '2345'} current_version = {'full': '2.1+git2345', 'version': '2.1', 'build': '2345'}
mock_platform.system.return_value = 'Linux' mock_platform.system.return_value = 'Linux'
mock_platform.release.return_value = '4.12.0-1-amd64' mock_platform.release.return_value = '4.12.0-1-amd64'
mock_get_web_page.return_value = '\n' mock_get_web_page.return_value = '\n'
@ -175,7 +175,7 @@ def test_worker_empty_response(mock_get_web_page, mock_platform):
# THEN: The check completes and the signal is emitted # THEN: The check completes and the signal is emitted
expected_download_url = 'https://get.openlp.org/versions/nightly_version.txt' expected_download_url = 'https://get.openlp.org/versions/nightly_version.txt'
expected_headers = {'User-Agent': 'OpenLP/2.1-bzr2345 Linux/4.12.0-1-amd64; '} expected_headers = {'User-Agent': 'OpenLP/2.1+git2345 Linux/4.12.0-1-amd64; '}
mock_get_web_page.assert_called_once_with(expected_download_url, headers=expected_headers) mock_get_web_page.assert_called_once_with(expected_download_url, headers=expected_headers)
assert mock_new_version.emit.call_count == 0 assert mock_new_version.emit.call_count == 0
mock_quit.emit.assert_called_once_with() mock_quit.emit.assert_called_once_with()