Skip to content

Commit

Permalink
Introduce a new flag about security bugfix only status
Browse files Browse the repository at this point in the history
  • Loading branch information
Gustry committed Jul 3, 2024
1 parent 022c5db commit 8f90218
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 28 deletions.
1 change: 1 addition & 0 deletions lizmap/definitions/definitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ def find_from_metadata(cls, metadata: dict):
class ReleaseStatus(Enum):
Unknown = 'Unknown'
Retired = 'Retired'
SecurityBugfixOnly = 'SecurityBugfixOnly'
Stable = 'Stable'
ReleaseCandidate = 'ReleaseCandidate'
Dev = 'Dev'
Expand Down
1 change: 1 addition & 0 deletions lizmap/test/test_definitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,4 @@ def test_release_status(self):
""" Test to retrieve release status. """
self.assertEqual(ReleaseStatus.find('feature_freeze'), ReleaseStatus.ReleaseCandidate)
self.assertEqual(ReleaseStatus.find('stable'), ReleaseStatus.Stable)
self.assertEqual(ReleaseStatus.find('security_bugfix_only'), ReleaseStatus.SecurityBugfixOnly)
48 changes: 20 additions & 28 deletions lizmap/version_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
import json
import logging

from typing import Tuple

from qgis.core import Qgis, QgsNetworkContentFetcher
from qgis.PyQt.QtCore import QDate, QLocale, QUrl

Expand All @@ -21,6 +19,9 @@
from lizmap.toolbelt.i18n import tr
from lizmap.toolbelt.plugin import lizmap_user_folder

# from typing import Tuple


LOGGER = logging.getLogger('Lizmap')
DAYS_BEING_OUTDATED = 90

Expand All @@ -37,7 +38,8 @@ def __init__(self, dialog: LizmapDialog, url: str, is_dev: bool):
self.date_newest_release_branch = None
self.oldest_release_branche = None
self.newest_release_branch = None
self.outdated = []
self.retired_versions = []
self.security_bugfix_only = []
self.is_dev = is_dev

def fetch(self):
Expand Down Expand Up @@ -71,22 +73,6 @@ def request_finished(self):
with open(lizmap_user_folder().joinpath("released_versions.json"), "w") as output:
output.write(content)

@classmethod
def version_status(cls, status: str) -> Tuple[ReleaseStatus, str]:
""" Return the release status according to the JSON content. """
if status == 'dev':
flag = ReleaseStatus.Dev
elif status == 'feature_freeze':
flag = ReleaseStatus.ReleaseCandidate
elif status == 'stable':
flag = ReleaseStatus.Stable
elif status == 'retired':
flag = ReleaseStatus.Retired
else:
flag = ReleaseStatus.Unknown

return flag, cls.status_display_string(flag)

@classmethod
def status_display_string(cls, status: ReleaseStatus) -> str:
""" Return a human display string status. """
Expand All @@ -96,10 +82,12 @@ def status_display_string(cls, status: ReleaseStatus) -> str:
return tr('Feature freeze')
elif status == ReleaseStatus.Stable:
return tr('Stable')
elif status == ReleaseStatus.SecurityBugfixOnly:
return tr('Security bugfix only')
elif status == ReleaseStatus.Retired:
return tr('Not maintained')
elif status is None or status == ReleaseStatus.Unknown:
return tr('Inconnu')
return tr('Unknown')
else:
raise Exception('Unknown status type : {}'.format(status))

Expand All @@ -120,7 +108,8 @@ def update_lwc_servers(self, released_versions: dict):
if lwc_version != version:
continue

flag, suffix = self.version_status(json_version.get('status'))
flag = LwcVersions.find(json_version.get('status'))
# suffix = self.status_display_string(flag)
self.dialog.server_combo.setItemData(index, flag, ServerComboData.LwcBranchStatus.value)

def update_lwc_releases(self, released_versions: dict):
Expand All @@ -147,10 +136,10 @@ def update_lwc_releases(self, released_versions: dict):
# if the Python source code is missing a version
lwc_version = LwcVersions.find(json_version['branch'], self.is_dev)

qdate = QDate.fromString(
q_date = QDate.fromString(
json_version['latest_release_date'],
"yyyy-MM-dd")
date_string = qdate.toString(QLocale().dateFormat(QLocale.ShortFormat))
date_string = q_date.toString(QLocale().dateFormat(QLocale.ShortFormat))
status = ReleaseStatus.find(json_version['status'])

changelog = json_version.get('changelog')
Expand Down Expand Up @@ -183,7 +172,7 @@ def update_lwc_releases(self, released_versions: dict):
if status == ReleaseStatus.Stable:
if i == 0:
self.dialog.lwc_version_latest.setText(text)
self.date_newest_release_branch = qdate
self.date_newest_release_branch = q_date
self.newest_release_branch = json_version['latest_release_version']

if link:
Expand All @@ -201,7 +190,7 @@ def update_lwc_releases(self, released_versions: dict):
elif i == 1:
single_stable_version_release = False
self.dialog.lwc_version_oldest.setText(text)
self.date_oldest_release_branch = qdate
self.date_oldest_release_branch = q_date
self.oldest_release_branche = json_version['latest_release_version']

if link:
Expand All @@ -210,8 +199,11 @@ def update_lwc_releases(self, released_versions: dict):

i += 1
elif status == ReleaseStatus.Retired:
if qdate.daysTo(QDate.currentDate()) > DAYS_BEING_OUTDATED:
self.outdated.append(lwc_version)
if q_date.daysTo(QDate.currentDate()) > DAYS_BEING_OUTDATED:
self.retired_versions.append(lwc_version)
elif status == ReleaseStatus.SecurityBugfixOnly:
if q_date.daysTo(QDate.currentDate()) > DAYS_BEING_OUTDATED:
self.security_bugfix_only.append(lwc_version)

if single_stable_version_release:
# We have only one single branch maintained, hide the oldest one.
Expand All @@ -220,7 +212,7 @@ def update_lwc_releases(self, released_versions: dict):

def check_outdated_version(self, lwc_version: LwcVersions, with_gui: True):
""" Display a warning about outdated LWC version. """
if lwc_version not in self.outdated:
if lwc_version not in self.retired_versions:
return

if with_gui:
Expand Down

0 comments on commit 8f90218

Please sign in to comment.