Atlas-Install/source/check_update.py
Faraphel 63f006af43
v0.4 (#2)
* added utf8 support to ct_config.json

* Updated track

* added 377 new tracks

* added 377 tracks to ct_config, also added tracks_list to make edtiting track way easier

* renamed (Vide).wu8 to just .wu8, to avoid problem with translation

* updated README.md

* added test files and distribution.txt to .gitignore

* added discord and wiki link

* game's version is now in definition.py

* update will now only enable if gitversion is newer than local version

* added math to lib

* renamed .wu8 to _.wu8

* removed 28 unused track

* replaced "" by "_"

* prepared version file

* Removed 5 unused files

* config tracks_list is now supported

* added missing game prefix

* A track name was too long for the game
2021-06-04 12:30:40 +02:00

37 lines
No EOL
1.7 KiB
Python

from . import *
import requests
import zipfile
import json
import sys
import os
VERSION_FILE_URL = "https://raw.githubusercontent.com/Faraphel/MKWF-Install/master/version"
def check_update(self):
try:
gitversion = requests.get(VERSION_FILE_URL, allow_redirects=True).json()
with open("version", "rb") as f:
locversion = json.load(f)
if gitversion["version"] > locversion["version"]:
if messagebox.askyesno(self.translate("Mise à jour disponible !"), self.translate("Une mise à jour est disponible, souhaitez-vous l'installer ?") +
f"\n\nVersion : {locversion['version']}.{locversion['subversion']} -> {gitversion['version']}.{gitversion['subversion']}\n"+\
f"Changelog :\n{gitversion['changelog']}"):
if not(os.path.exists("./Updater/Updater.exe")):
dl = requests.get(gitversion["updater_bin"], allow_redirects=True)
with open("./download.zip", "wb") as file:
print(self.translate("Téléchargement de Updater en cours..."))
file.write(dl.content)
print(self.translate("fin du téléchargement, début de l'extraction..."))
with zipfile.ZipFile("./download.zip") as file:
file.extractall("./Updater/")
print(self.translate("fin de l'extraction"))
os.remove("./download.zip")
print(self.translate("lancement de l'application..."))
os.startfile(os.path.realpath("./Updater/Updater.exe"))
sys.exit()
except Exception as e:
print(e)