From dbc0bab3e2ae336b3ef56eb316dbe67ce4a954da Mon Sep 17 00:00:00 2001 From: Ambulance Clerc Date: Mon, 6 Jun 2022 13:31:13 +0200 Subject: [PATCH] =?UTF-8?q?ajout=20syst=C3=A8me=20auto-update?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + auto_update.py | 32 ++++++++++++++++++++++++++++++++ dl_version | 2 +- main.py | 9 ++++++++- version.py | 2 +- 5 files changed, 43 insertions(+), 3 deletions(-) create mode 100644 .gitignore create mode 100644 auto_update.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b2e2f7c --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/update.exe diff --git a/auto_update.py b/auto_update.py new file mode 100644 index 0000000..3398eba --- /dev/null +++ b/auto_update.py @@ -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 + + + diff --git a/dl_version b/dl_version index 1e7efc5..288aad3 100644 --- a/dl_version +++ b/dl_version @@ -1 +1 @@ -202200606-1107 \ No newline at end of file +20220606-1330 \ No newline at end of file diff --git a/main.py b/main.py index bdb736e..44c6413 100644 --- a/main.py +++ b/main.py @@ -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 diff --git a/version.py b/version.py index 042f19d..0b55b17 100644 --- a/version.py +++ b/version.py @@ -1 +1 @@ -VERSION = "202200602 - 1700" \ No newline at end of file +VERSION = "20220606-1330" \ No newline at end of file