#!/bin/sh # UX-13 P5: regenerate the DOCS screenshots in docs/img/ux13/ from the real page. # # sh goodwe_controller/tools/ux13_screenshots.sh [OUT_DIR] # # Serves tools/ux13_demo.py's fixtures (running, shadow, new, setup) in the CI # test image, then runs tools/ux13_screenshots.py in the Playwright image on a # private Docker network (the image has the browsers; the matching Python # package is installed into the container on each run). Nothing talks to Home Assistant or an inverter. The # prices and the "now" line follow the clock, so the pictures change a little # from run to run. Needs Docker and PyPI access; pulls the Playwright image once. set -eu HERE=$(cd "$(dirname "$0")/.." && pwd) OUT=${1:-$HERE/../docs/img/ux13} PW=mcr.microsoft.com/playwright/python:v1.55.0-noble NET=ux13-shots-$$ STATES="running shadow new setup" mkdir -p "$OUT" OUT=$(cd "$OUT" && pwd) cleanup() { for s in $STATES; do docker rm -f "$NET-$s" >/dev/null 2>&1 || true; done docker network rm "$NET" >/dev/null 2>&1 || true } trap cleanup EXIT INT TERM docker build -q -t goodwe-addon-checks:1 "$HERE/../.gitea/ci" >/dev/null docker network create "$NET" >/dev/null ENVS="" for s in $STATES; do docker run -d --name "$NET-$s" --network "$NET" -e PYTHONDONTWRITEBYTECODE=1 \ -v "$HERE:/w:ro" goodwe-addon-checks:1 \ python3 /w/tools/ux13_demo.py "$s" 8099 0.0.0.0 >/dev/null ENVS="$ENVS -e DEMO_$(echo "$s" | tr a-z A-Z)=http://$NET-$s:8099/" done sleep 3 # shellcheck disable=SC2086 docker run --rm --network "$NET" --user "$(id -u):$(id -g)" -e HOME=/tmp \ $ENVS -v "$HERE/tools:/t:ro" -v "$OUT:/out" "$PW" \ sh -euc 'pip install -q --disable-pip-version-check --target /tmp/pw \ playwright==1.55.0 PYTHONPATH=/tmp/pw python3 /t/ux13_screenshots.py /out' echo "screenshots in $OUT"