From f1d91d7b547196fd4cb5980f467369fee7ab5595 Mon Sep 17 00:00:00 2001 From: jmbeach Date: Wed, 13 Sep 2023 09:51:17 -0400 Subject: [PATCH] windows support If the user is on Windows, download alternate binaries from another repo --- const.py | 5 +++-- manage.py | 9 +++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/const.py b/const.py index fcb69dc..5415ef3 100644 --- a/const.py +++ b/const.py @@ -4,7 +4,8 @@ import os BASE_URL_DICTIONARIES = "https://api.github.com/repos/wooorm/dictionaries/contents" -URL_BINARIES = "https://github.com/jankelemen/convert-dict-tool-from-chromium/archive/refs/heads/master.zip" +URL_BINARIES = "https://github.com/jankelemen/convert-dict-tool-from-chromium/archive/refs/heads/master.zip"\ + if os.name != 'nt' else 'https://github.com/jmbeach/convert_dict_windows/archive/refs/heads/main.zip' VERSION_DICTIONARIES = "2a5353f1617f00e606dc036cab1c37df94272ca0" URL_DICTIONARIES = lambda path: f"{BASE_URL_DICTIONARIES}/{path}?ref={VERSION_DICTIONARIES}" @@ -14,7 +15,7 @@ ENABLED_PATH = os.path.join(USER_PATH, "enabled.pck") USER_DICT_PATH = os.path.join(USER_PATH, "user_dics") BINS_PATH = os.path.join(ADDON_PATH, "convert_dict") -BIN_PATH = os.path.join(ADDON_PATH, "convert_dict", "convert_dict") +BIN_PATH = os.path.join(ADDON_PATH, "convert_dict", "convert_dict" if os.name != 'nt' else "convert_dict.exe") PERSONAL_PATH = os.path.join(USER_PATH, "user_dics", "personal.txt") try: diff --git a/manage.py b/manage.py index fabc721..c76376d 100644 --- a/manage.py +++ b/manage.py @@ -108,10 +108,11 @@ def checkConversionBinaries(*args): def compileBDIC(path, name, remove=False): - command = [BIN_PATH + " " + os.path.join(path, name)] - mode = os.stat(BIN_PATH).st_mode - mode |= (mode & 0o444) >> 2 # copy R bits to X - os.chmod(BIN_PATH, mode) + command = [BIN_PATH, os.path.join(path, name)] + if os.name != 'nt': + mode = os.stat(BIN_PATH).st_mode + mode |= (mode & 0o444) >> 2 # copy R bits to X + os.chmod(BIN_PATH, mode) res = subprocess.run(command, shell=True, capture_output=True, text=True) if remove: ex = [".dic", ".aff"]