try/except for getting version

This commit is contained in:
BarsTiger
2022-03-20 20:27:41 +02:00
parent 0bd8ddeb62
commit 2f1a27ffa2
2 changed files with 12 additions and 5 deletions

View File

@@ -27,8 +27,12 @@ if not os.path.exists(launcherfiles):
if __name__ == "__main__":
urllib.request.urlretrieve(appslisturl, launcherfiles + "apps.json")
with open(launcherfiles + "/v") as v_file:
v = int(v_file.read())
try:
with open(launcherfiles + "/v") as v_file:
v = int(v_file.read())
except:
v = -1
if v < int(requests.get(launcherversionurl).text):
urllib.request.urlretrieve(launcherurl, "KOTIKOT_launcher.py")
urllib.request.urlretrieve(guiurl, launcherfiles + "KOTIKOTlauncherMain.py")
@@ -82,8 +86,11 @@ def launchApp():
download_app(app)
else:
with open(directory + "/v") as v_file:
v = int(v_file.read())
try:
with open(directory + "/v") as v_file:
v = int(v_file.read())
except:
v = -1
if v < int(requests.get('/'.join(app['urls'][0].split('/')[:-1]) + '/v').text):
print('Current app version is ' + str(v) + ' and new version is '
+ requests.get('/'.join(app['urls'][0].split('/')[:-1]) + '/v').text)