Enable version checking
This commit is contained in:
parent
3f9e5457f6
commit
e7f937ecd2
@ -262,7 +262,7 @@ Have fun!
|
||||
self.settings.show_disclaimer = not checked
|
||||
|
||||
if self.settings.check_for_new_version:
|
||||
pass
|
||||
self.check_latest_version_online()
|
||||
|
||||
def open_file_event(self, url: QtCore.QUrl) -> None:
|
||||
logger.info(url.toLocalFile())
|
||||
@ -2121,19 +2121,19 @@ Have fun!
|
||||
version_checker.get_latest_version(self.settings.install_id, self.settings.send_usage_stats)
|
||||
)
|
||||
|
||||
def version_check_complete(self, new_version: str) -> None:
|
||||
if new_version not in (self.version, self.settings.dont_notify_about_this_version):
|
||||
def version_check_complete(self, new_version: tuple[str, str]) -> None:
|
||||
if new_version[0] not in (self.version, self.settings.dont_notify_about_this_version):
|
||||
website = "https://github.com/comictagger/comictagger"
|
||||
checked = OptionalMessageDialog.msg(
|
||||
self,
|
||||
"New version available!",
|
||||
f"New version ({new_version}) available!<br>(You are currently running {self.version})<br><br>"
|
||||
f"Visit <a href='{website}'>{website}</a> for more info.<br><br>",
|
||||
f"New version ({new_version[1]}) available!<br>(You are currently running {self.version})<br><br>"
|
||||
f"Visit <a href='{website}/releases/latest'>{website}/releases/latest</a> for more info.<br><br>",
|
||||
False,
|
||||
"Don't tell me about this version again",
|
||||
)
|
||||
if checked:
|
||||
self.settings.dont_notify_about_this_version = new_version
|
||||
self.settings.dont_notify_about_this_version = new_version[0]
|
||||
|
||||
def on_incoming_socket_connection(self) -> None:
|
||||
# Accept connection from other instance.
|
||||
|
@ -16,8 +16,6 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
import platform
|
||||
import sys
|
||||
|
||||
import requests
|
||||
|
||||
@ -29,31 +27,23 @@ logger = logging.getLogger(__name__)
|
||||
class VersionChecker:
|
||||
def get_request_url(self, uuid: str, use_stats: bool) -> tuple[str, dict[str, str]]:
|
||||
|
||||
base_url = "http://comictagger1.appspot.com/latest"
|
||||
params = {}
|
||||
if use_stats:
|
||||
params = {"uuid": uuid, "version": ctversion.version}
|
||||
if platform.system() == "Windows":
|
||||
params["platform"] = "win"
|
||||
elif platform.system() == "Linux":
|
||||
params["platform"] = "lin"
|
||||
elif platform.system() == "Darwin":
|
||||
params["platform"] = "mac"
|
||||
else:
|
||||
params["platform"] = "other"
|
||||
|
||||
if not getattr(sys, "frozen", None):
|
||||
params["src"] = "T"
|
||||
base_url = "https://api.github.com/repos/comictagger/comictagger/releases/latest"
|
||||
params: dict[str, str] = {}
|
||||
|
||||
return base_url, params
|
||||
|
||||
def get_latest_version(self, uuid: str, use_stats: bool = True) -> str:
|
||||
def get_latest_version(self, uuid: str, use_stats: bool = True) -> tuple[str, str]:
|
||||
try:
|
||||
url, params = self.get_request_url(uuid, use_stats)
|
||||
new_version = requests.get(url, params=params).text
|
||||
release = requests.get(
|
||||
url,
|
||||
params=params,
|
||||
headers={"user-agent": "comictagger/" + ctversion.version},
|
||||
).json()
|
||||
except Exception:
|
||||
return ""
|
||||
return ("", "")
|
||||
|
||||
new_version = release["tag_name"]
|
||||
if new_version is None or new_version == "":
|
||||
return ""
|
||||
return new_version.strip()
|
||||
return ("", "")
|
||||
return (new_version.strip(), release["name"])
|
||||
|
Loading…
Reference in New Issue
Block a user