Skip to content
Snippets Groups Projects
Commit 6568475b authored by Andre Maroneze's avatar Andre Maroneze
Browse files

[analysis-scripts] apply suggested improvement by malberti

parent a7075cd8
No related branches found
No related tags found
No related merge requests found
...@@ -48,22 +48,18 @@ def get_command(command: str, env_var_name: str) -> Path | None: ...@@ -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).""" then in the PATH, then in the resource directory (for a pyinstaller binary)."""
if command in cached_commands: if command in cached_commands:
return cached_commands[command] 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: if p_str:
p = Path(p_str) p = Path(p_str)
else: else:
p_str = shutil.which(command) p = Path(resource_path(command))
if p_str: if not p.exists():
p = Path(p_str) if emit_warns:
else: print(
p = Path(resource_path(command)) f"info: optional external command '{command}' not found in PATH;",
if not p.exists(): f"consider installing it or setting environment variable {env_var_name}",
if emit_warns: )
print( p = None
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 cached_commands[command] = p
return p return p
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment