From 6568475bc968af8fe3f93bcf7ab9ef810e7275c4 Mon Sep 17 00:00:00 2001 From: Andre Maroneze <andre.maroneze@cea.fr> Date: Mon, 22 Jul 2024 14:35:28 +0200 Subject: [PATCH] [analysis-scripts] apply suggested improvement by malberti --- share/analysis-scripts/external_tool.py | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/share/analysis-scripts/external_tool.py b/share/analysis-scripts/external_tool.py index 717980c638..29f47bd257 100644 --- a/share/analysis-scripts/external_tool.py +++ b/share/analysis-scripts/external_tool.py @@ -48,22 +48,18 @@ def get_command(command: str, env_var_name: str) -> Path | None: then in the PATH, then in the resource directory (for a pyinstaller binary).""" if command in cached_commands: return cached_commands[command] - p_str = os.getenv(env_var_name) + p_str = os.getenv(env_var_name) or shutil.which(command) if p_str: p = Path(p_str) else: - p_str = shutil.which(command) - if p_str: - p = Path(p_str) - else: - p = Path(resource_path(command)) - if not p.exists(): - if emit_warns: - print( - f"info: optional external command '{command}' not found in PATH;", - f"consider installing it or setting environment variable {env_var_name}", - ) - p = None + p = Path(resource_path(command)) + if not p.exists(): + if emit_warns: + print( + f"info: optional external command '{command}' not found in PATH;", + f"consider installing it or setting environment variable {env_var_name}", + ) + p = None cached_commands[command] = p return p -- GitLab