bottleclip: Do not require write access to the bottle-clip dir
This commit is contained in:
parent
deced2d3a7
commit
7011c67e2e
1 changed files with 9 additions and 3 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue