🐛[bugfix] Model : github apiのアクセス制限時にエラーとならないように修正

This commit is contained in:
misyaguziya committed 2024-11-11 00:24:27 +09:00
1 parent e96d267c92
commit 3721a55704
1 file changed
+12 -5
+12 -5
View File
@@ -8,8 +8,9 @@ from logging import getLogger, FileHandler, Formatter, INFO
from time import sleep from time import sleep
from queue import Queue from queue import Queue
from threading import Thread 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 flashtext import KeywordProcessor
from models.translation.translation_translator import Translator from models.translation.translation_translator import Translator
from models.transcription.transcription_utils import getInputDevices, getOutputDevices from models.transcription.transcription_utils import getInputDevices, getOutputDevices
@@ -304,10 +305,16 @@ class Model:
# check update # check update
update_flag = False update_flag = False
response = requests_get(config.GITHUB_URL) response = requests_get(config.GITHUB_URL)
new_version = response.json()["name"] json_data = response.json()
if new_version != config.VERSION:
update_flag = True version = json_data.get("name", None)
print("software version", "now:", config.VERSION, "new:", new_version) 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 return update_flag
@staticmethod @staticmethod