Amélioration système auto-update
This commit is contained in:
@@ -3,30 +3,32 @@ import urllib.request
|
|||||||
import ssl
|
import ssl
|
||||||
import io
|
import io
|
||||||
|
|
||||||
|
class auto_updater:
|
||||||
|
dl_version = 0
|
||||||
|
|
||||||
def clean(str):
|
def clean(self, str):
|
||||||
str = str.replace('/','')
|
str = str.replace('/','')
|
||||||
str = str.replace(':', '')
|
str = str.replace(':', '')
|
||||||
str = str.replace('{', '')
|
str = str.replace('{', '')
|
||||||
str = str.replace('(', '')
|
str = str.replace('(', '')
|
||||||
str = str.replace("\\", '')
|
str = str.replace("\\", '')
|
||||||
return str
|
return str
|
||||||
|
|
||||||
def new_update_available():
|
def new_update_available(self):
|
||||||
ret = False
|
ret = False
|
||||||
ctx = ssl.create_default_context()
|
ctx = ssl.create_default_context()
|
||||||
ctx.check_hostname = False
|
ctx.check_hostname = False
|
||||||
ctx.verify_mode = ssl.CERT_NONE
|
ctx.verify_mode = ssl.CERT_NONE
|
||||||
|
|
||||||
data = urllib.request.urlopen("https://gitea.prod.resk-u.ch/CLERC/AttribWinbiz/raw/branch/master/dl_version", context=ctx)
|
data = urllib.request.urlopen("https://gitea.prod.resk-u.ch/CLERC/AttribWinbiz/raw/branch/master/dl_version", context=ctx)
|
||||||
dl_version = str(data.read()).replace('b', '').replace("'", "")
|
self.dl_version = str(data.read()).replace('b', '').replace("'", "")
|
||||||
|
|
||||||
ssl._create_default_https_context = ssl._create_unverified_context
|
ssl._create_default_https_context = ssl._create_unverified_context
|
||||||
if dl_version != VERSION:
|
if self.dl_version != VERSION:
|
||||||
print(f"Version différente trouvée {dl_version} téléchargement en cours")
|
print(f"Version différente trouvée {self.dl_version} téléchargement en cours")
|
||||||
urllib.request.urlretrieve(url=f"https://gitea.prod.resk-u.ch/CLERC/AttribWinbiz/releases/download/{clean(dl_version)}/Clercattrib2Biz_setup.exe", filename="update.exe")
|
urllib.request.urlretrieve(url=f"https://gitea.prod.resk-u.ch/CLERC/AttribWinbiz/releases/download/{self.clean(self.dl_version)}/Clercattrib2Biz_setup.exe", filename="update.exe")
|
||||||
ret = True
|
ret = True
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
4
main.py
4
main.py
@@ -252,7 +252,9 @@ class ClercAttrib2Biz():
|
|||||||
|
|
||||||
self.thread = Thread(target=self.start_parsing)
|
self.thread = Thread(target=self.start_parsing)
|
||||||
|
|
||||||
if new_update_available():
|
auto_update = auto_updater()
|
||||||
|
if auto_update.new_update_available():
|
||||||
|
self.logger.warning(f"Nouvelle version du script disponible. {auto_update.dl_version}")
|
||||||
if messagebox.askyesno(title="Nouvelle version trouvée", message=f"Une nouvelle version a été trouvée, vous pouvez l'installer dès maintenant !", ):
|
if messagebox.askyesno(title="Nouvelle version trouvée", message=f"Une nouvelle version a été trouvée, vous pouvez l'installer dès maintenant !", ):
|
||||||
subprocess.call("update.exe")
|
subprocess.call("update.exe")
|
||||||
self.fenetre.destroy()
|
self.fenetre.destroy()
|
||||||
|
@@ -1 +1 @@
|
|||||||
VERSION = "20220606-1330"
|
VERSION = "20220606-1331"
|
Reference in New Issue
Block a user