diff --git a/flower_pot.py b/flower_pot.py old mode 100644 new mode 100755 index 6211b3b..90aa65d --- a/flower_pot.py +++ b/flower_pot.py @@ -5,7 +5,7 @@ import subprocess import sys from pathlib import Path -from utils import ask_float +from utils import ask_float, check_openscad BASE_DIR = Path(__file__).resolve().parent @@ -42,6 +42,8 @@ def render_scad(scad_file: Path, out_file: Path, base_radius: float, wall_height def main() -> None: + check_openscad() + if not SCAD_DIR.exists(): raise SystemExit(f"Missing SCAD directory: {SCAD_DIR}") diff --git a/parametric_box.py b/parametric_box.py old mode 100644 new mode 100755 index dae5a01..32bfa94 --- a/parametric_box.py +++ b/parametric_box.py @@ -5,7 +5,7 @@ import subprocess import sys from pathlib import Path -from utils import ask_float +from utils import ask_float, check_openscad BASE_DIR = Path(__file__).resolve().parent @@ -49,6 +49,8 @@ def render_scad( def main() -> None: + check_openscad() + if not SCAD_DIR.exists(): raise SystemExit(f"Missing SCAD directory: {SCAD_DIR}") diff --git a/pill_container.py b/pill_container.py old mode 100644 new mode 100755 index f706813..bcafceb --- a/pill_container.py +++ b/pill_container.py @@ -6,7 +6,7 @@ import subprocess import sys from pathlib import Path -from utils import ask_float, ask_int, ask_yes_no +from utils import ask_float, ask_int, ask_yes_no, check_openscad BASE_DIR = Path(__file__).resolve().parent @@ -70,6 +70,8 @@ def render_scad( def main() -> None: + check_openscad() + if not SCAD_DIR.exists(): raise SystemExit(f"Missing SCAD directory: {SCAD_DIR}") diff --git a/seedling_tray.py b/seedling_tray.py old mode 100644 new mode 100755 index 2147d6f..f109cd8 --- a/seedling_tray.py +++ b/seedling_tray.py @@ -5,7 +5,7 @@ import subprocess import sys from pathlib import Path -from utils import ask_int, ask_float +from utils import ask_int, ask_float, check_openscad BASE_DIR = Path(__file__).resolve().parent @@ -54,6 +54,8 @@ def render_scad( def main() -> None: + check_openscad() + if not SCAD_DIR.exists(): raise SystemExit(f"Missing SCAD directory: {SCAD_DIR}") diff --git a/utils.py b/utils.py index c5b832d..0d9ccac 100644 --- a/utils.py +++ b/utils.py @@ -1,5 +1,6 @@ #!/bin/python3 from __future__ import annotations +import shutil def ask_int(prompt: str) -> int: @@ -39,3 +40,10 @@ def ask_yes_no(prompt: str) -> bool: return False print("Please enter yes or no. [y/n]") + +def check_openscad() -> None: + if shutil.which("openscad") is None: + raise SystemExit( + "OpenSCAD was not found in PATH. " + "Install OpenSCAD or make sure the 'openscad' command is available." + ) diff --git a/weave_planter.py b/weave_planter.py index 49f3ec3..a73c23d 100755 --- a/weave_planter.py +++ b/weave_planter.py @@ -1,12 +1,11 @@ #!/bin/python3 from __future__ import annotations -import shutil import subprocess import sys from pathlib import Path -from utils import ask_float +from utils import ask_float, check_openscad BASE_DIR = Path(__file__).resolve().parent @@ -58,11 +57,7 @@ def render_scad( def main() -> None: - if shutil.which("openscad") is None: - raise SystemExit( - "OpenSCAD was not found in PATH. " - "Install OpenSCAD or make sure the 'openscad' command is available." - ) + check_openscad() scad_file = SCAD_DIR / "weave_planter.scad"