ajout système auto-update

This commit is contained in:
Ambulance Clerc
2022-06-06 13:31:13 +02:00
parent 66da1c212a
commit dbc0bab3e2
5 changed files with 43 additions and 3 deletions

1
.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
/update.exe

32
auto_update.py Normal file
View File

@@ -0,0 +1,32 @@
from version import *
import urllib.request
import ssl
import io
def clean(str):
str = str.replace('/','')
str = str.replace(':', '')
str = str.replace('{', '')
str = str.replace('(', '')
str = str.replace("\\", '')
return str
def new_update_available():
ret = False
ctx = ssl.create_default_context()
ctx.check_hostname = False
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)
dl_version = str(data.read()).replace('b', '').replace("'", "")
ssl._create_default_https_context = ssl._create_unverified_context
if dl_version != VERSION:
print(f"Version différente trouvée {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")
ret = True
return ret

View File

@@ -1 +1 @@
202200606-1107
20220606-1330

View File

@@ -3,6 +3,7 @@ import json
import os
import logging
import shutil
import subprocess
import textwrap
import time
import uuid
@@ -18,8 +19,9 @@ from threading import *
from class_invoices import *
from class_addresses import *
from auto_update import *
VERSION = "202200602 - 1700"
from version import *
#test master 2
src_dir = os.getenv('APPDATA') + "\Attrib2Biz\src"
@@ -250,6 +252,11 @@ class ClercAttrib2Biz():
self.thread = Thread(target=self.start_parsing)
if new_update_available():
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")
self.fenetre.destroy()
def draw_addressesWindows(self):
# Init de la fenêtre addresses prompt

View File

@@ -1 +1 @@
VERSION = "202200602 - 1700"
VERSION = "20220606-1330"