1
0
mirror of https://github.com/esphome/esphome.git synced 2025-06-18 22:35:40 +01:00

adjust to new python pre-commit hooks ()

Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com>
This commit is contained in:
tomaszduda23
2024-08-12 06:52:09 +02:00
committed by GitHub
parent 8a076cc906
commit f13cf1f7a0
2 changed files with 29 additions and 15 deletions

@ -159,20 +159,19 @@ def get_binary(name: str, version: str) -> str:
binary_file = f"{name}-{version}"
try:
result = subprocess.check_output([binary_file, "-version"])
if result.returncode == 0:
return binary_file
except Exception:
return binary_file
except FileNotFoundError:
pass
binary_file = name
try:
result = subprocess.run(
[binary_file, "-version"], text=True, capture_output=True
[binary_file, "-version"], text=True, capture_output=True, check=False
)
if result.returncode == 0 and (f"version {version}") in result.stdout:
return binary_file
raise FileNotFoundError(f"{name} not found")
except FileNotFoundError as ex:
except FileNotFoundError:
print(
f"""
Oops. It looks like {name} is not installed. It should be available under venv/bin