-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdater.py
More file actions
35 lines (28 loc) · 1.05 KB
/
Copy pathupdater.py
File metadata and controls
35 lines (28 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
from __future__ import annotations
import requests
from PyQt6.QtCore import QThread, pyqtSignal
class UpdateChecker(QThread):
update_found = pyqtSignal(str, str) # (new_version, html_url)
def __init__(self, current: str) -> None:
super().__init__()
self._current = current
def run(self) -> None:
try:
r = requests.get(
"https://api.github.com/repos/Eadroma/RiotAccountManager/releases/latest",
timeout=5,
headers={"Accept": "application/vnd.github.v3+json"},
)
r.raise_for_status()
data = r.json()
tag = data.get("tag_name", "").lstrip("v")
url = data.get("html_url", "")
if tag and url and _version_gt(tag, self._current):
self.update_found.emit(tag, url)
except Exception:
pass
def _version_gt(a: str, b: str) -> bool:
try:
return tuple(int(x) for x in a.split(".")) > tuple(int(x) for x in b.split("."))
except ValueError:
return False