-
Notifications
You must be signed in to change notification settings - Fork 15
/
updater.py
49 lines (31 loc) · 1.09 KB
/
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
39
40
41
42
43
44
45
46
47
import sys
import requests
import platform
import json
from packaging import version
import utils
def current_version():
major = "1"
minor = "4"
patch = "0"
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 get_branch():
return "Stable"
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())
def get_type():
return f'System: {platform.system()}, Frozen: {is_frozen()}'