mirror of
https://github.com/maziggy/bambuddy.git
synced 2026-09-30 03:01:21 +02:00
Sliced files previewed through a vendored copy of PrettyGCode in an iframe. It drew each move as a screen-space line -- a line has no thickness in the scene, so it cannot occlude the layer behind it, which is why prints came out stringy and shimmered where layers crossed. Being a separate app in a frame, it could be neither themed nor translated, and carried its own machinery for detecting a proxy refusing the embed. Now built on libvgcode, the renderer OrcaSlicer draws its own preview with, vendored from three-slicer (AGPL, same as us). It takes the THREE namespace as an argument and imports nothing, so it runs on our 0.181 rather than the 0.160 its package pins. The parser is ours; upstream renders its own kernel's output and ships no G-code parser at all. Two things it has to get right, both found by checking a real plate rather than assuming: - BambuStudio does not use the OrcaSlicer/PrusaSlicer annotations. It writes "; FEATURE:", "; LINE_WIDTH:", "; CHANGE_LAYER" and "; Z_HEIGHT:", not ";TYPE:", ";WIDTH:" and ";LAYER_CHANGE". Reading only the latter showed a 52-layer print as 23,165 layers in one colour, because with no layer marker recognised every travel Z-hop split a layer and every segment took the fallback feature. - It emits a tenth of its moves as G2/G3 arcs -- 706 extruding ones in a single plate. Ignoring them punched holes through curved walls and tree supports. Arcs with no X/Y are the helical travel lift and lay down nothing, so they interpolate as travels. Four colour modes: filament (default, from the AMS slots the file was sliced with), feature, layer height, line width. Speed, fan and temperature are deliberately absent -- upstream derives those from settings rather than the toolpath, and guesses dressed as measurements are worse than an honest omission. The parser now carries the data to do them properly later. Legend entries are switches. Hiding removes the records before the mesh is built rather than recolouring them: the shader packs colour into a single float with no alpha, so there is no transparent to set, and removal is the useful behaviour anyway -- a hidden support stops occluding what it covered. The scene is built once and only the toolpath rebuilds. Doing otherwise constructed a new WebGLRenderer on every render, because the buildVolume default is an object literal and so a fresh identity each time; browsers cap live WebGL contexts and drop the oldest, which blanked the canvas after a few interactions. utils/framing.ts goes with the iframe, along with six now-orphaned strings in all 13 locales. src/lib/vendor is excluded from eslint -- acting on findings in vendored code makes it impossible to re-copy on the next upstream release.
72 lines
3.1 KiB
Python
72 lines
3.1 KiB
Python
"""Reinstalling must not silently take away a writable path (#2544).
|
|
|
|
``ProtectSystem=strict`` means the unit's ``ReadWritePaths`` is the *complete*
|
|
list of places Bambuddy can write. An operator who backs up to a NAS adds their
|
|
share to it by hand — and both installers overwrite the unit file wholesale, so
|
|
that line used to vanish on the next install. The backups then failed with EROFS
|
|
every night, which looks like a NAS permission problem and is not one.
|
|
|
|
So the installers keep the operator's extra paths, and the unit says why they
|
|
matter.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from pathlib import Path
|
|
|
|
import pytest
|
|
|
|
REPO = Path(__file__).resolve().parents[3]
|
|
|
|
INSTALLERS = ["install/install.sh", "spoolbuddy/install/install.sh"]
|
|
|
|
# The service unit + install scripts these tests read live at the repo root and
|
|
# are not copied into the Docker test image (Dockerfile.test ships only backend/,
|
|
# pyproject.toml and requirements). In a source checkout they are
|
|
# always present and the guard below is live; in the stripped test image there is
|
|
# nothing to check, so skip rather than fail. `frontend/package.json` exists in
|
|
# every checkout but never in the test image, so it distinguishes the two.
|
|
pytestmark = pytest.mark.skipif(
|
|
not (REPO / "frontend" / "package.json").is_file(),
|
|
reason="launcher config files aren't shipped in the Docker test image; verified in native runs",
|
|
)
|
|
|
|
|
|
def _read(rel: str) -> str:
|
|
path = REPO / rel
|
|
assert path.is_file(), f"launcher moved or was removed: {rel}"
|
|
return path.read_text()
|
|
|
|
|
|
class TestUnitTemplate:
|
|
def test_readwritepaths_still_grants_the_three_app_dirs(self):
|
|
unit = _read("deploy/bambuddy.service")
|
|
line = next(line for line in unit.splitlines() if line.startswith("ReadWritePaths="))
|
|
assert "DATA_DIR" in line and "LOG_DIR" in line and "INSTALL_PATH" in line
|
|
|
|
def test_unit_explains_how_to_add_a_backup_share(self):
|
|
"""Whoever reads this unit next has to be able to work out why their NAS
|
|
is read-only for the service but not for their shell.
|
|
"""
|
|
unit = _read("deploy/bambuddy.service")
|
|
assert "systemctl edit" in unit, "the unit should show how to add a writable path via a drop-in"
|
|
|
|
|
|
class TestInstallersPreserveCustomPaths:
|
|
@pytest.mark.parametrize("installer", INSTALLERS)
|
|
def test_generated_unit_appends_the_carried_over_paths(self, installer):
|
|
script = _read(installer)
|
|
line = next(line for line in script.splitlines() if line.startswith("ReadWritePaths="))
|
|
assert "$extra_rw" in line, (
|
|
f"{installer} writes ReadWritePaths without $extra_rw, so a NAS share the operator "
|
|
"added to the unit is dropped on reinstall:\n" + line
|
|
)
|
|
|
|
@pytest.mark.parametrize("installer", INSTALLERS)
|
|
def test_existing_unit_is_read_for_custom_paths_and_backed_up(self, installer):
|
|
script = _read(installer)
|
|
assert "ReadWritePaths=" in script and "extra_rw+=" in script, (
|
|
f"{installer} no longer carries the previous unit's ReadWritePaths forward"
|
|
)
|
|
assert ".bak-" in script, f"{installer} overwrites the unit without backing it up first"
|