-
Notifications
You must be signed in to change notification settings - Fork 3
/
updateManager.py
52 lines (41 loc) · 1.53 KB
/
updateManager.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
48
49
50
51
52
import logging
import platform
import requests
import infoManager
logging.basicConfig(level=logging.DEBUG,
format='%(name)s:%(levelname)s:%(message)s')
class updateManager:
def __init__(self):
self.__url: str = 'https://rizwan-hasan.github.io/Free-Hash-Checker/updates.json'
self.__updateData: dict = {
'version': infoManager.informationManger().version
}
try:
self.__updateData = requests.get(self.__url).json()
except requests.exceptions.ConnectionError:
logging.warning('No Internet! Can\'t check updates')
def haveUpdate(self):
if self.__updateData['version'] != infoManager.informationManger(
).version:
return True
else:
return False
def __checkUpdate(self):
try:
self.__updateData = requests.get(self.__url).json()
return True
except requests.exceptions.ConnectionError:
logging.warning('No Internet! Can\'t check updates')
return False
def getUpdateData(self):
if platform.system().lower() == 'windows':
del self.__updateData['linux']
self.__updateData['update'] = self.__updateData['windows']
del self.__updateData['windows']
else:
del self.__updateData['windows']
self.__updateData['update'] = self.__updateData['linux']
del self.__updateData['linux']
return self.__updateData
if __name__ == "__main__":
print('Hello World')