-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathversion.py
60 lines (51 loc) · 1.71 KB
/
version.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
53
54
55
56
57
58
59
60
import os
import json
import logging
import requests
import traceback
def getVersion():
try:
contents = None
path = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'version')
with open(path, 'r') as reader:
contents = reader.read().strip()
if contents.isnumeric():
return {
'version': contents,
'build': contents,
}
return json.loads(contents)
except FileNotFoundError:
logging.error(f'Error reading Magpie\'s version: file "version" not found')
except Exception as e:
logging.error(f'Error reading Magpie\'s version: {traceback.format_exc()}')
return {
"version": "Unknown",
"build": "Unknown"
}
def getRemoteVersion():
try:
request = requests.get('https://magpietracker.us/api/version')
version = json.loads(request.text)
if 'magpieDisplay' in version:
version['magpie'] = { 'version': version['magpieDisplay'], 'build': version['magpie'] }
del version['magpieDisplay']
else:
version['magpie'] = { 'version': version['magpie'], 'build': version['magpie'] }
return version
except:
return None
def getAutotrackerVersion():
try:
path = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'autotracker-version')
with open(path, 'r') as reader:
return reader.read().strip()
except:
return 'unknown'
def getUpdateMessage():
try:
path = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'updateMessage')
with open(path, 'r') as reader:
return reader.read().strip()
except:
return None