From 7011c67e2ede48075cd86d06ece70420a7a72a51 Mon Sep 17 00:00:00 2001 From: polyfloyd Date: Fri, 9 May 2025 17:32:09 +0200 Subject: [PATCH] bottleclip: Do not require write access to the bottle-clip dir --- bottleclip.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/bottleclip.py b/bottleclip.py index a386bee..c6fc2e6 100644 --- a/bottleclip.py +++ b/bottleclip.py @@ -19,20 +19,26 @@ def list_icons() -> List[str]: def create_stl(label: str, icon: str, ears: bool) -> NamedTemporaryFile: icon_path = abspath(join(resource_dir(), "icons", icon)) ears_str = "true" if ears else "false" + font_path = abspath(join(resource_dir(), "write/orbitron.dxf")) - scad = NamedTemporaryFile(dir=resource_dir(), suffix=".scad") + scad = NamedTemporaryFile(suffix=".scad") with open(join(resource_dir(), "bottle-clip.scad"), "rb") as f: scad.write(f.read()) scad.write(b"\n\n") scad.write( - f'bottle_clip(name="{label}", logo="{icon_path}", ears={ears_str});'.encode( + f'bottle_clip(name="{label}", logo="{icon_path}", ears={ears_str}, font="{font_path}");'.encode( "utf-8" ) ) scad.flush() stl = NamedTemporaryFile(suffix=".scad") - subprocess.run(["openscad", scad.name, "--export-format", "binstl", "-o", stl.name]) + subprocess.run( + ["openscad", scad.name, "--export-format", "binstl", "-o", stl.name], + env={ + "OPENSCADPATH": resource_dir(), + }, + ) stl.seek(0) return stl