From 4872a18e91c5594517ae6507d54f043aae41489e Mon Sep 17 00:00:00 2001 From: 2Shirt <2xShirt@gmail.com> Date: Wed, 5 May 2021 23:10:38 -0600 Subject: [PATCH 1/2] Support tools with multiple architectures --- scripts/wk/kit/tools.py | 9 ++++++++- scripts/wk/repairs/win.py | 7 ++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/scripts/wk/kit/tools.py b/scripts/wk/kit/tools.py index 4aef66e3..b9282a16 100644 --- a/scripts/wk/kit/tools.py +++ b/scripts/wk/kit/tools.py @@ -63,6 +63,7 @@ def download_file(out_path, source_url, as_new=False, overwrite=False): def download_tool(folder, name): """Download tool.""" + name_arch = f'{name}{ARCH}' out_path = find_kit_dir('.bin').joinpath(f'{folder}/{name}.exe') up_to_date = False @@ -77,9 +78,15 @@ def download_tool(folder, name): LOG.info('Skip downloading up-to-date tool: %s', name) return + # Get ARCH specific URL if available + if name_arch in SOURCES: + source_url = SOURCES[name_arch] + out_path = out_path.with_stem(name_arch) + else: + source_url = SOURCES[name] + # Download LOG.info('Downloading tool: %s', name) - source_url = SOURCES[name] try: new_file = download_file(out_path, source_url, as_new=True) new_file.replace(out_path) diff --git a/scripts/wk/repairs/win.py b/scripts/wk/repairs/win.py index c21c4c3f..6d161458 100644 --- a/scripts/wk/repairs/win.py +++ b/scripts/wk/repairs/win.py @@ -20,7 +20,7 @@ from wk.exe import ( wait_for_procs, ) from wk.io import delete_folder, rename_item -from wk.kit.tools import ARCH, download_tool, get_tool_path, run_tool +from wk.kit.tools import download_tool, get_tool_path, run_tool from wk.log import format_log_path, update_log_path from wk.os.win import ( reg_delete_value, @@ -817,10 +817,7 @@ def run_hitmanpro(): log_path = log_path.with_suffix('.xml') log_path.parent.mkdir(parents=True, exist_ok=True) cmd_args = ['/scanonly', f'/log={log_path}'] - run_tool( - 'HitmanPro', f'HitmanPro{"64" if ARCH=="64" else ""}', - *cmd_args, download=True, - ) + run_tool('HitmanPro', 'HitmanPro', *cmd_args, download=True) def run_iobit_uninstaller(): From 6a00444bd4b73964aab77adc78cf7c1cf10fd3ed Mon Sep 17 00:00:00 2001 From: 2Shirt <2xShirt@gmail.com> Date: Wed, 5 May 2021 23:29:29 -0600 Subject: [PATCH 2/2] Support multiple architectures in get_tool_path() This change was necessary to avoid using the wrong paths for tools with speparate executables for different architectures. --- scripts/wk/kit/tools.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/scripts/wk/kit/tools.py b/scripts/wk/kit/tools.py index b9282a16..e24ae07b 100644 --- a/scripts/wk/kit/tools.py +++ b/scripts/wk/kit/tools.py @@ -147,10 +147,12 @@ def find_kit_dir(name=None): def get_tool_path(folder, name, check=True): """Get tool path, returns pathlib.Path""" bin_dir = find_kit_dir('.bin') + name_arch = f'{name}{ARCH}' # "Search" - tool_path = bin_dir.joinpath(f'{folder}/{name}{ARCH}.exe') - if not tool_path.exists(): + tool_path = bin_dir.joinpath(f'{folder}/{name_arch}.exe') + if not (tool_path.exists() or name_arch in SOURCES): + # Use "default" path instead tool_path = tool_path.with_stem(name) # Missing?