-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathGN Interton Checker.py
122 lines (100 loc) · 4.83 KB
/
GN Interton Checker.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#############################################################
# #
# Copyright Bluebotlabz #
# #
#############################################################
import requests
from pathlib import Path
from colorama import just_fix_windows_console
from colorama import Fore, Back, Style
import libhearingdownloader
import xml.etree.ElementTree as xml
just_fix_windows_console()
print("\n\n")
print("==================================================")
print("= " + Style.BRIGHT + Fore.YELLOW + "Interton" + Style.RESET_ALL + " Software Update Checker =")
print("="*(47-len(libhearingdownloader.downloaderVersion)) + " " + Fore.GREEN + libhearingdownloader.downloaderVersion + Style.RESET_ALL + " =")
turboFile = Path("turbo.txt")
if not turboFile.is_file():
libhearingdownloader.printWaranty()
disclaimer = [
"DISCLAIMER",
"",
"The contributors of the Hearing Aids Fitting Software Update Checkers (\"The Checker\")",
"do not take any responsability for what you do with The Checker.",
"",
"Interton does not review the content of The Checker or the source that The Checker check against",
"Please view the source disclaimer at:"
"http://www.supportgn.com/interton/subsites/disclaimer.php",
"",
"Interton is a trademark of GN Hearing A/S and/or its affiliates (\"GN Group\")",
"GN is a trademark of GN Hearing A/S",
"Interton Fitting is a trademark of GN Hearing A/S",
"GN Hearing A/S is a subsidiary of GN Hearing A/S",
"Interton is a subsidiary of GN Hearing A/S",
"Interton Fitting is created by Interton",
"Appraise is created by Interton",
"CompuFit is created by Interton"
"All rights and credit go to their rightful owners. No copyright infringement intended.",
"",
"The contributors of The Checker, and The Checker itself are not affiliated with or endorsed by",
"Interton, GN Hearing A/S, GN Group or GN Hearing A/S",
"Depending on how The Checker is used, it may violate the EULA and/or Terms and Conditions of the associated software.",
"The Checker is an UNOFFICIAL project and the use of associated software may be limited."
]
# Define variables
rootDownloadURL = "http://www.supportgn.com/files/"
# Display disclaimer
if not turboFile.is_file():
libhearingdownloader.printDisclaimer(disclaimer)
updaterRetries = libhearingdownloader.updaterRetries
while updaterRetries > 0:
try:
# Download update file list from updater API
rawXmlData = requests.get("http://www.supportgn.com/interton/subsites/releasessdb.xml")
data = xml.fromstring(rawXmlData.text)
break
except:
pass
updaterRetries -= 1
if (updaterRetries == 0):
print("\n" + Fore.RED + "Error" + Style.RESET_ALL + ": Update server could not be reached")
exit(1)
if (libhearingdownloader.verboseDebug):
print(rawXmlData.text)
# Define XMLNS (the main one)
availableFiles = {} # List of available files
currentCategory = "Other"
for child in data:
if (child[0].tag == "SEPARATOR"):
#availableFiles.append( ("== " + child[0].text + " ==", '--') )
currentCategory = child[0].text
else:
#availableFiles.append( (child.find("BUTTONTEXTDOWN").text, '', child.find("LINK").text) )
availableFiles[currentCategory] = availableFiles.get(currentCategory, [])
availableFiles[currentCategory].append( (child.find("BUTTONTEXTDOWN").text, '', child.find("LINK").text) )
if (libhearingdownloader.verboseDebug):
print(availableFiles)
print("\n\nThe latest available version is " + Fore.GREEN + list(availableFiles.keys())[0] + Style.RESET_ALL + "\n\n")
categories = []
for category in availableFiles.keys():
categories.append( (category, "") )
# Select outputDir and targetFile
outputDir = libhearingdownloader.selectOutputFolder()
simpleSelection = libhearingdownloader.selectFromList(categories, prompt="category to download from", headerSeperator='\n')
targetCategory = categories[simpleSelection][0]
if (libhearingdownloader.verboseDebug):
print(targetCategory)
availableFiles = availableFiles[targetCategory]
selectedFile = libhearingdownloader.selectFromList(availableFiles, prompt="software to download", headerSeperator='\n')
targetURL = availableFiles[selectedFile][2]
targetFile = availableFiles[selectedFile]
if (not ("http://" in targetURL or "https://" in targetURL)):
targetURL = rootDownloadURL + targetURL
# Create download folder
#outputDir += '.'.join(targetFile[0].split('.')[:-1]) + "/"
outputLocation = outputDir + '.'.join(targetFile[2].split("/")[-1].split(".")[:-1]) + "/" + targetFile[2].split("/")[-1]
print("\n\n")
# Download file
libhearingdownloader.downloadFile(targetURL, outputLocation, "Downloading " + targetFile[0])
print("\n\nDownload Complete!")