-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathupdater.py
38 lines (26 loc) · 977 Bytes
/
updater.py
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
36
37
38
import sys
import requests
import json
from packaging import version
import utils
def current_version():
major = "1"
minor = "4"
patch = "1"
version_number = f"{major}.{minor}.{patch}"
# "outofdate": a test meant for checking update-related functions
if utils.is_test("outofdate"):
version_number = "1.0.0"
return version_number
def latest_version():
return json.loads(requests.get("https://api.github.com/repos/dhtdht020/osc-dl/releases/latest").content)
def is_frozen():
"""Check if frozen with PyInstaller"""
return getattr(sys, 'frozen', False) and hasattr(sys, '_MEIPASS')
def check_update(updated_version):
"""
Checks if updated_version is higher than current OSCDL version
:param updated_version: Dictionary containing information regarding a release from the GitHub API.
:return: True if higher.
"""
return version.parse(updated_version["tag_name"]) > version.parse(current_version())