from version import * import urllib.request import ssl import io class auto_updater: dl_version = 0 temp_dir = "" def clean(self, str): str = str.replace('/','') str = str.replace(':', '') str = str.replace('{', '') str = str.replace('(', '') str = str.replace("\\", '') return str def new_update_available(self): 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) self.dl_version = str(data.read()).replace('b', '').replace("'", "") ssl._create_default_https_context = ssl._create_unverified_context if self.dl_version != VERSION: print(f"Version différente trouvée {self.dl_version} téléchargement en cours => {self.temp_dir}update.exe") try: urllib.request.urlretrieve(url=f"https://gitea.prod.resk-u.ch/CLERC/AttribWinbiz/releases/download/{self.clean(self.dl_version)}/Clercattrib2Biz_setup.exe", filename=f"{self.temp_dir}update.exe") except: print("ERREUR de téléchargement mise à jours") return "ERROR" ret = True return ret