fce0b8d9a1
setenv.bat (and activate_venv/get_cmd/install_py.bat) had a UTF-8 BOM, which cmd.exe read as part of the @echo off line, breaking every bin script that calls setenv.bat via `call`. Stripped the BOM. material_flow.bat/.sh and tro_flow.bat/.sh now check up front whether the Graphviz engine --tosvg needs (dot, or neato with --use-cords) is resolvable, and print an early WARNUNG with fix instructions if not - before the CSV is even parsed. The Python scripts still run and report the same failure in detail if the SVG step is actually reached.
52 lines
1.9 KiB
Bash
52 lines
1.9 KiB
Bash
#!/usr/bin/env bash
|
|
# ================================================================
|
|
# SPS_SKEL - Materialfluss-Graph erzeugen
|
|
# ================================================================
|
|
# Aufruf:
|
|
# bash bin/material_flow.sh --file export.csv
|
|
# bash bin/material_flow.sh --file export.csv --tosvg
|
|
#
|
|
# Die CSV-Datei wird in $SKEL_DATA gesucht, DOT und SVG werden
|
|
# in $SKEL_RESULTS abgelegt.
|
|
# ================================================================
|
|
|
|
set -eu
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
|
|
# Umgebung setzen (SKEL_DATA, SKEL_RESULTS, SKEL_LIB, PYTHONPATH ...)
|
|
# shellcheck source=/dev/null
|
|
. "$SCRIPT_DIR/setenv.sh" >/dev/null
|
|
|
|
# Virtuelle Umgebung nutzen, falls vorhanden
|
|
if [ -f "$SPS_SKEL/.venv/bin/activate" ]; then
|
|
# shellcheck source=/dev/null
|
|
. "$SPS_SKEL/.venv/bin/activate"
|
|
fi
|
|
|
|
# Python-Interpreter bestimmen
|
|
PY="python3"
|
|
command -v python3 >/dev/null 2>&1 || PY="python"
|
|
|
|
# Graphviz pruefen, wenn --tosvg SVG erzeugen soll (dot, bei --use-cords/
|
|
# --use-coords neato) - nur ein frueher Hinweis; das eigentliche Skript
|
|
# meldet denselben Fehler beim Rendern noch einmal im Detail.
|
|
case " $* " in
|
|
*" --tosvg "*)
|
|
GV_ENGINE="dot"
|
|
case " $* " in
|
|
*" --use-cords "*|*" --use-coords "*) GV_ENGINE="neato" ;;
|
|
esac
|
|
if ! command -v "$GV_ENGINE" >/dev/null 2>&1; then
|
|
if [ "$GV_ENGINE" != "dot" ] || [ -z "${GRAPHVIZ_DOT:-}" ]; then
|
|
echo "WARNUNG: Graphviz '$GV_ENGINE' nicht im PATH gefunden - --tosvg wird vermutlich fehlschlagen." >&2
|
|
echo " Graphviz installieren (https://graphviz.org/download/), PATH ergaenzen," >&2
|
|
echo " oder GRAPHVIZ_DOT auf die dot-Programmdatei setzen (nur fuer 'dot')." >&2
|
|
echo "" >&2
|
|
fi
|
|
fi
|
|
;;
|
|
esac
|
|
|
|
exec "$PY" "$SKEL_LIB/material_flow.py" "$@"
|