From 3721a55704ca4252aa28fa706f02ee5c6c21bbbb Mon Sep 17 00:00:00 2001 From: misyaguziya <53165965+misyaguziya@users.noreply.github.com> Date: Mon, 11 Nov 2024 00:24:27 +0900 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B[bugfix]=20Model=20:=20github=20api?= =?UTF-8?q?=E3=81=AE=E3=82=A2=E3=82=AF=E3=82=BB=E3=82=B9=E5=88=B6=E9=99=90?= =?UTF-8?q?=E6=99=82=E3=81=AB=E3=82=A8=E3=83=A9=E3=83=BC=E3=81=A8=E3=81=AA?= =?UTF-8?q?=E3=82=89=E3=81=AA=E3=81=84=E3=82=88=E3=81=86=E3=81=AB=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- model.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/model.py b/model.py index df5bc8ba..58b587a4 100644 --- a/model.py +++ b/model.py @@ -8,8 +8,9 @@ from logging import getLogger, FileHandler, Formatter, INFO from time import sleep from queue import Queue from threading import Thread -from requests import get as requests_get +from packaging.version import parse +from requests import get as requests_get from flashtext import KeywordProcessor from models.translation.translation_translator import Translator from models.transcription.transcription_utils import getInputDevices, getOutputDevices @@ -304,10 +305,16 @@ class Model: # check update update_flag = False response = requests_get(config.GITHUB_URL) - new_version = response.json()["name"] - if new_version != config.VERSION: - update_flag = True - print("software version", "now:", config.VERSION, "new:", new_version) + json_data = response.json() + + version = json_data.get("name", None) + if isinstance(version, str): + new_version = parse(version) + current_version = parse(config.VERSION) + if new_version > current_version: + update_flag = True + print("software version", "now:", config.VERSION, "new:", version) + return update_flag @staticmethod