Grotti 3.7.0: Treiber für Kobra 4 und Marlin, smartere Dateien-Auswahl und einstellbare Etiketten.

Senden und Abbruch laufen über den Treiber, Orca-Doppelzeilen und tote Ideen-API fallen weg, Drucker folgen der Datei, Etikettenformat liegt in den Einstellungen.
This commit is contained in:
Dominic Gundel committed 2026-11-02 14:03:57 +01:00
1 parent 5081212212
commit db6a85a703
54 files changed
+3379 -384

No files matched your search

+25 -6
View File
@@ -94,7 +94,14 @@ def load_config(path: Path = CONFIG_PATH) -> dict[str, str]:
browser = str(data.get("browser") or "app").strip().lower() or "app"
if browser not in ("app", "tab"):
browser = "app"
return {"url": url, "token": token, "browser": browser}
# Windows-Pfad des Slice-Ordners, wenn Grotti auf dem Pi läuft (dort anderer Pfad)
watch_local = str(data.get("watch_dir_local") or data.get("watch_dir") or "").strip()
return {
"url": url,
"token": token,
"browser": browser,
"watch_dir_local": watch_local,
}
def is_gcode_path(path: Path) -> bool:
@@ -287,6 +294,16 @@ def fetch_watch_dir(base_url: str, token: str) -> Path | None:
return path if path.is_dir() else None
def resolve_watch_dir(config: dict) -> Path | None:
"""Lokaler Slice-Ordner: Config zuerst, sonst der Pfad von Grotti (gleiche Maschine)."""
local = str(config.get("watch_dir_local") or "").strip()
if local:
path = Path(local)
if path.is_dir():
return path
return fetch_watch_dir(config["url"], config["token"])
def under_watch(watch_dir: Path, target: Path) -> tuple[str, str] | None:
"""(folder_relativ, dateiname) wenn target unter watch_dir liegt."""
try:
@@ -450,9 +467,11 @@ def open_browser(
webbrowser.open(url)
def deliver(base_url: str, token: str, src: Path) -> int:
def deliver(config: dict, src: Path) -> int:
"""Datei in Slice-Unterordner legen oder hochladen; gibt file_id zurück."""
watch = fetch_watch_dir(base_url, token)
base_url = config["url"]
token = config["token"]
watch = resolve_watch_dir(config)
target = output_target()
if watch is not None and target is not None:
placed = under_watch(watch, target)
@@ -482,10 +501,10 @@ def main(argv: list[str] | None = None) -> int:
path = find_gcode_arg(argv)
write_debug(
argv,
"chosen=%s\nupload_as=%s\noutput=%s"
% (path, upload_name_for(path), output_target() or ""),
"chosen=%s\nupload_as=%s\noutput=%s\nwatch_local=%s"
% (path, upload_name_for(path), output_target() or "", config.get("watch_dir_local") or ""),
)
file_id = deliver(config["url"], config["token"], path)
file_id = deliver(config, path)
name = upload_name_for(path)
write_debug(argv, "file_id=%s\nupload_as=%s" % (file_id, name))
mode = str(config.get("browser") or "app").strip().lower()