diff --git a/source/__init__.py b/source/__init__.py index 5dc7a50..b536c58 100644 --- a/source/__init__.py +++ b/source/__init__.py @@ -19,6 +19,7 @@ def __init__(self): self.ctconfig = CT_Config() self.ctconfig.load_ctconfig_file("./ct_config.json") + self.is_dev_version = False # Is this installer version a dev ? self.stringvar_language = StringVar(value=self.option["language"]) self.stringvar_game_format = StringVar(value=self.option["format"]) self.boolvar_disable_download = BooleanVar(value=self.option["disable_download"]) @@ -36,8 +37,6 @@ def __init__(self): self.root.iconbitmap(bitmap="./icon.ico") if not(self.boolvar_dont_check_for_update.get()): self.check_update() - self.path_mkwf = None - self.menu_bar = Menu(self.root) self.root.config(menu=self.menu_bar) diff --git a/source/check_update.py b/source/check_update.py index c407020..f2cce4d 100644 --- a/source/check_update.py +++ b/source/check_update.py @@ -13,15 +13,15 @@ def check_update(self): with open("./version", "rb") as f: locversion = json.load(f) - if ((float(gitversion["version"]) > float(locversion["version"])) or - (float(gitversion["version"]) == float(locversion["version"])) and + if ((float(gitversion["version"]) > float(locversion["version"])) or # if github version is newer than + (float(gitversion["version"]) == float(locversion["version"])) and # local version float(gitversion["subversion"]) > float(locversion["subversion"])): if messagebox.askyesno( self.translate("Update available !"), self.translate("An update is available, do you want to install it ?", - f"\n\nVersion : {locversion['version']}.{locversion['subversion']} -> " - f"{gitversion['version']}.{gitversion['subversion']}\n" - f"Changelog :\n{gitversion['changelog']}")): + f"\n\nVersion : {locversion['version']}.{locversion['subversion']} -> " + f"{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) @@ -38,6 +38,11 @@ def check_update(self): print(self.translate("starting application...")) os.startfile(os.path.realpath("./Updater/Updater.exe")) + if ((float(gitversion["version"]) < float(locversion["version"])) or # if local version is newer than + (float(gitversion["version"]) == float(locversion["version"])) and # github version + float(gitversion["subversion"]) < float(locversion["subversion"])): + self.is_dev_version = True + except requests.ConnectionError: messagebox.showwarning(self.translate("Warning"), self.translate("Can't connect to internet. Download will be disabled.")) diff --git a/source/definition.py b/source/definition.py index b749f22..08035e5 100644 --- a/source/definition.py +++ b/source/definition.py @@ -1,7 +1,10 @@ CREATE_NO_WINDOW = 0x08000000 GITHUB_REPOSITORY = "Faraphel/MKWF-Install" -GITHUB_CONTENT_ROOT = f"https://raw.githubusercontent.com/{GITHUB_REPOSITORY}/master/" -VERSION_FILE_URL = GITHUB_CONTENT_ROOT + "version" +GITHUB_MASTER_BRANCH = f"https://raw.githubusercontent.com/{GITHUB_REPOSITORY}/master/" +GITHUB_DEV_BRANCH = f"https://raw.githubusercontent.com/{GITHUB_REPOSITORY}/dev/" +VERSION_FILE_URL = GITHUB_MASTER_BRANCH + "version" + +get_github_content_root = lambda self: GITHUB_DEV_BRANCH if self.is_dev_version else GITHUB_MASTER_BRANCH get_filename = lambda file: ".".join(file.split(".")[:-1]) get_nodir = lambda file: file.replace("\\", "/").split("/")[-1] diff --git a/source/get_github_file.py b/source/get_github_file.py index 02361e7..b035286 100644 --- a/source/get_github_file.py +++ b/source/get_github_file.py @@ -9,7 +9,7 @@ def get_github_file(self, file): returncode = 0 if self.boolvar_disable_download.get(): return 2 - dl = requests.get(GITHUB_CONTENT_ROOT+file, allow_redirects=True, stream=True) + dl = requests.get(get_github_content_root(self)+file, allow_redirects=True, stream=True) if os.path.exists(file): if int(dl.headers['Content-Length']) == os.path.getsize(file): return 1 else: returncode = 3 diff --git a/source/install_mod.py b/source/install_mod.py index aedae4c..11f3e26 100644 --- a/source/install_mod.py +++ b/source/install_mod.py @@ -132,4 +132,6 @@ def install_mod(self): t = Thread(target=func) t.setDaemon(True) t.start() - return t \ No newline at end of file + return t + +# TODO: use wszst module instead of subprocess