From a8ada2aa7e8aabf601a5058f1909f0e0beb625ed Mon Sep 17 00:00:00 2001 From: Etienne Trimaille Date: Thu, 21 Dec 2023 18:10:50 +0100 Subject: [PATCH] Checks - Add QGIS server version check in the table --- lizmap/dialogs/main.py | 8 +++++--- lizmap/plugin.py | 4 +++- lizmap/tools.py | 3 +++ lizmap/widgets/check_project.py | 33 +++++++++++++++++++++++++++++++++ 4 files changed, 44 insertions(+), 4 deletions(-) diff --git a/lizmap/dialogs/main.py b/lizmap/dialogs/main.py index 24c5401c..dc0be2e5 100755 --- a/lizmap/dialogs/main.py +++ b/lizmap/dialogs/main.py @@ -554,7 +554,7 @@ def follow_map_theme_toggled(self): if current_text.endswith(text): self.combo_legend_option.setCurrentText(current_text.replace(text, '')) - def check_qgis_version(self, message_bar=False, widget=False): + def check_qgis_version(self, message_bar=False, widget=False) -> bool: """ Compare QGIS desktop and server versions and display results if necessary. """ self.warning_old_server.setVisible(False) @@ -567,11 +567,11 @@ def check_qgis_version(self, message_bar=False, widget=False): qgis_server = (int(qgis_server[0]), int(qgis_server[1])) except AttributeError: # Maybe returning LWC 3.4 or LWC 3.5 without the server plugin - return + return False if qgis_server >= qgis_desktop: # Alright - return + return False title = tr('QGIS server version is lower than QGIS desktop version') LOGGER.error(title) @@ -605,6 +605,8 @@ def check_qgis_version(self, message_bar=False, widget=False): ).format(qgis_server, qgis_desktop) self.warning_old_server.set_text(message) + return True + def current_server_info(self, info: ServerComboData): """ Return the current LWC server information from the server combobox. """ return self.server_combo.currentData(info) diff --git a/lizmap/plugin.py b/lizmap/plugin.py index c743af8b..f2bce7ba 100755 --- a/lizmap/plugin.py +++ b/lizmap/plugin.py @@ -3176,6 +3176,9 @@ def project_config_file( Error(Path(self.project.fileName()).name, checks.EmptyBaseLayersGroup) ) + if self.dlg.check_qgis_version(message_bar=True): + self.dlg.check_results.add_error(Error(tr('Global'), checks.ServerVersion)) + # Not blocking, we change it in the background if self.project.readNumEntry("WMSMaxAtlasFeatures", '')[0] <= 0: LOGGER.info("The maximum atlas features was less than '1'. We set it to '1' to at least have a value.") @@ -3890,7 +3893,6 @@ def save_cfg_file( variables['lizmap_repository'] = self.dlg.current_repository() self.project.setCustomVariables(variables) - self.dlg.check_qgis_version(message_bar=True) if not lwc_version: lwc_version = self.current_lwc_version() diff --git a/lizmap/tools.py b/lizmap/tools.py index 6cc55ffd..84a091a1 100755 --- a/lizmap/tools.py +++ b/lizmap/tools.py @@ -155,6 +155,7 @@ def current_git_hash() -> str: hash_number = git_show.communicate()[0].partition('\n')[0] except IndexError: # Reported on redmine + # Was-it due to Python 3.7.0 ? # IndexError: list index out of range hash_number = '' @@ -179,6 +180,7 @@ def has_git() -> bool: output = git_show.communicate()[0].partition('\n')[0] except IndexError: # Reported on redmine + # Was-it due to Python 3.7.0 ? # IndexError: list index out of range output = '' @@ -201,6 +203,7 @@ def next_git_tag(): tag = git_show.communicate()[0].partition('\n')[0] except IndexError: # Reported on redmine + # Was-it due to Python 3.7.0 ? # IndexError: list index out of range tag = '' diff --git a/lizmap/widgets/check_project.py b/lizmap/widgets/check_project.py index d85cc62f..29b5e654 100644 --- a/lizmap/widgets/check_project.py +++ b/lizmap/widgets/check_project.py @@ -268,6 +268,39 @@ def __init__(self): Severities().low, QIcon(':/images/themes/default/mIconWms.svg'), ) + self.ServerVersion = Check( + 'old_qgis_server_version', + tr('QGIS server version is lower than QGIS desktop version'), + tr( + "QGIS desktop is writing QGS project file in the future compare to QGIS server. QGIS server might not " + "be able to read the file correctly. Versions between desktop and server must be equal, or QGIS server " + "can have a newer version." + ), + ( + '' + ).format( + upgrade=tr("Either upgrade your QGIS Server"), + downgrade=tr("Or downgrade your QGIS Desktop"), + ), + Levels.GlobalConfig, + Severities().important, + QIcon(':/images/icons/qgis_icon.svg'), + ( + '' + ).format( + upgrade=tr( + "Either check if an upgrade of QGIS server is available in Lizmap Web Client, in the " + "administration panel. Current LTR versions should be available." + ), + downgrade=tr("Or downgrade your QGIS Desktop"), + ), + ) self.PkInt8 = Check( 'primary_key_bigint', tr('Invalid bigint (integer8) field for QGIS Server as primary key'),