[FIX] export.lsp: klare Fehlermeldung statt Lisp-Crash bei fehlendem DXFM_LIB
Ist BricsCAD nicht ueber bin/start_briscad.bat gestartet worden, ist DXFM_LIB in der Sitzung nicht gesetzt. Bisher liess das (strcat (getenv "DXFM_LIB") ...) mit "bad argument type <NIL> ; expected <STRING>" abstuerzen. Jetzt wird das vorher geprueft und ueber ssg-textf (exp-dxfm-lib-missing, de/en) gemeldet; JSON/CSV-Sammlung laeuft weiter, nur der Python-Aufruf entfaellt.
This commit is contained in:
+43
-34
@@ -626,43 +626,52 @@
|
||||
(close fh)
|
||||
(princ (ssg-textf "exp-json-written" (list label out-pfad)))
|
||||
|
||||
;; Python-Skript aufrufen
|
||||
(setq py-skript (strcat (getenv "DXFM_LIB") "/" py-name))
|
||||
(if (findfile py-skript)
|
||||
;; Python-Skript aufrufen. DXFM_LIB muss gesetzt sein - fehlt es
|
||||
;; (z.B. weil BricsCAD nicht ueber bin/start_briscad.bat gestartet
|
||||
;; wurde und die Umgebungsvariablen daher nie in diesen Prozess
|
||||
;; vererbt wurden), wuerde das folgende strcat sonst mit einem
|
||||
;; kryptischen Lisp-Fehler ("bad argument type <NIL>") abbrechen.
|
||||
(if (null (getenv "DXFM_LIB"))
|
||||
(princ (ssg-textf "exp-dxfm-lib-missing" (list label)))
|
||||
(progn
|
||||
(setq ergebnis-pfad (strcat out-dir "/" csv-name))
|
||||
(setq py-exe (export:python-exe))
|
||||
(setq log-pfad (strcat (cond ((getenv "DXFM_LOG")) (out-dir))
|
||||
"/export_python.log"))
|
||||
(princ (ssg-textf "exp-python-exe" (list label py-exe)))
|
||||
(princ (ssg-textf "exp-calling-python" (list label)))
|
||||
;; Synchron ausfuehren und Exitcode auswerten - ein stiller
|
||||
;; Fehlschlag (z.B. WindowsApps-Platzhalter statt Interpreter)
|
||||
;; darf nicht mehr als "Export gestartet" durchgehen.
|
||||
(setq rc (export:run-python py-exe py-skript
|
||||
(list out-pfad (getenv "DXFM_DATA") ergebnis-pfad)
|
||||
log-pfad))
|
||||
(cond
|
||||
((null rc)
|
||||
(princ (ssg-textf "exp-python-call-failed" (list label))))
|
||||
((/= rc 0)
|
||||
(princ (ssg-textf "exp-python-error" (list label rc log-pfad)))
|
||||
(export:log-ausgeben log-pfad 12)
|
||||
;; Exitcode 49 (Store-Platzhalter direkt) bzw. 9009 (cmd.exe:
|
||||
;; "Befehl nicht gefunden") = kein brauchbarer Interpreter.
|
||||
;; Gezielter Hinweis, wie er korrekt gesetzt wird.
|
||||
(if (or (= rc 49) (= rc 9009)
|
||||
(export:python-store-stub-p py-exe))
|
||||
(princ (ssg-text "exp-python-store-hint"))
|
||||
))
|
||||
((not (findfile ergebnis-pfad))
|
||||
(princ (ssg-textf "exp-csv-missing" (list label ergebnis-pfad log-pfad)))
|
||||
(export:log-ausgeben log-pfad 12))
|
||||
(t
|
||||
(princ (ssg-textf "exp-export-done" (list label ergebnis-pfad))))
|
||||
(setq py-skript (strcat (getenv "DXFM_LIB") "/" py-name))
|
||||
(if (findfile py-skript)
|
||||
(progn
|
||||
(setq ergebnis-pfad (strcat out-dir "/" csv-name))
|
||||
(setq py-exe (export:python-exe))
|
||||
(setq log-pfad (strcat (cond ((getenv "DXFM_LOG")) (out-dir))
|
||||
"/export_python.log"))
|
||||
(princ (ssg-textf "exp-python-exe" (list label py-exe)))
|
||||
(princ (ssg-textf "exp-calling-python" (list label)))
|
||||
;; Synchron ausfuehren und Exitcode auswerten - ein stiller
|
||||
;; Fehlschlag (z.B. WindowsApps-Platzhalter statt Interpreter)
|
||||
;; darf nicht mehr als "Export gestartet" durchgehen.
|
||||
(setq rc (export:run-python py-exe py-skript
|
||||
(list out-pfad (getenv "DXFM_DATA") ergebnis-pfad)
|
||||
log-pfad))
|
||||
(cond
|
||||
((null rc)
|
||||
(princ (ssg-textf "exp-python-call-failed" (list label))))
|
||||
((/= rc 0)
|
||||
(princ (ssg-textf "exp-python-error" (list label rc log-pfad)))
|
||||
(export:log-ausgeben log-pfad 12)
|
||||
;; Exitcode 49 (Store-Platzhalter direkt) bzw. 9009 (cmd.exe:
|
||||
;; "Befehl nicht gefunden") = kein brauchbarer Interpreter.
|
||||
;; Gezielter Hinweis, wie er korrekt gesetzt wird.
|
||||
(if (or (= rc 49) (= rc 9009)
|
||||
(export:python-store-stub-p py-exe))
|
||||
(princ (ssg-text "exp-python-store-hint"))
|
||||
))
|
||||
((not (findfile ergebnis-pfad))
|
||||
(princ (ssg-textf "exp-csv-missing" (list label ergebnis-pfad log-pfad)))
|
||||
(export:log-ausgeben log-pfad 12))
|
||||
(t
|
||||
(princ (ssg-textf "exp-export-done" (list label ergebnis-pfad))))
|
||||
)
|
||||
)
|
||||
(princ (ssg-textf "exp-python-not-found" (list label py-skript)))
|
||||
)
|
||||
)
|
||||
(princ (ssg-textf "exp-python-not-found" (list label py-skript)))
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
@@ -499,6 +499,7 @@
|
||||
"exp-json-written": "\n[%1] JSON geschrieben: %2",
|
||||
"exp-calling-python": "\n[%1] Rufe Python auf...",
|
||||
"exp-export-started": "\n[%1] Export gestartet: %2",
|
||||
"exp-dxfm-lib-missing": "\n[%1] FEHLER: Umgebungsvariable DXFM_LIB ist nicht gesetzt - BricsCAD wurde vermutlich nicht ueber bin/start_briscad.bat gestartet. CSV/JSON wurden geschrieben, der Python-Aufruf entfaellt.",
|
||||
"exp-python-not-found": "\n[%1] FEHLER: Python-Skript nicht gefunden: %2",
|
||||
"exp-python-exe": "\n[%1] Interpreter: %2",
|
||||
"exp-export-done": "\n[%1] Export fertig: %2",
|
||||
|
||||
@@ -499,6 +499,7 @@
|
||||
"exp-json-written": "\n[%1] JSON written: %2",
|
||||
"exp-calling-python": "\n[%1] Calling Python...",
|
||||
"exp-export-started": "\n[%1] Export started: %2",
|
||||
"exp-dxfm-lib-missing": "\n[%1] ERROR: Environment variable DXFM_LIB is not set - BricsCAD was probably not started via bin/start_briscad.bat. CSV/JSON were written, the Python call is skipped.",
|
||||
"exp-python-not-found": "\n[%1] ERROR: Python script not found: %2",
|
||||
"exp-python-exe": "\n[%1] Interpreter: %2",
|
||||
"exp-export-done": "\n[%1] Export finished: %2",
|
||||
|
||||
Reference in New Issue
Block a user