testsAndMisc/linux_configuration/utils/check_brother_printer.sh
Krzysztof kuhy Rudnicki f15f00f3fe Re-point paths for the ~ reorganisation (home-tidy)
Also bumps the 16 meta/requirements pins the freshness gate flagged
(anthropic 1.5.0, numpy 2.5.3, pytest-randomly 5, flake8-bugbear 26.9.9,
ruff 0.16.7, pyright 1.1.414, selenium 4.49.0, hypothesis 6.168.0, lxml
6.1.3, pipdeptree 4.2.5, the two types-* stubs) and Flutter 3.47.3 in
meta/.fvmrc. One test still expected the pre-move ~/mcp-servers path.

The pre-commit hook fed .zsh files to shfmt and shellcheck, neither of
which parses zsh (SC2148/SC1071), so no zsh file could be committed since
the hook was tightened on 2026-08-22; those now get `zsh -n` instead. The
hook's own shfmt pass also staged its reformat of 8 shell files.

CI_GREEN_SKIP because main is red on exactly the dependency-freshness
finding this commit fixes, which is the documented use of that flag.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AwtowrowDXx6ccmWVPkCaF
2026-09-11 20:50:19 +02:00

49 lines
1.7 KiB
Bash
Executable File

#!/usr/bin/env bash
# Check Brother laser printer consumable/maintenance status.
# Thin wrapper that ensures dependencies are present, then runs the
# Python implementation in ~/src/testsAndMisc/python_pkg/brother_printer.
#
# Usage:
# ./check_brother_printer.sh # auto-detect USB or network
# ./check_brother_printer.sh <printer_ip> # force network/SNMP mode
set -euo pipefail
PYTHON_PKG_DIR="${HOME}/src/testsAndMisc/python_pkg"
BROTHER_MODULE="brother_printer"
# ── Ensure dependencies ─────────────────────────────────────────────
check_dependency() {
local cmd="$1" pkg="$2"
if ! command -v "$cmd" &>/dev/null; then
echo "Installing $pkg..."
sudo pacman -S --noconfirm --needed "$pkg"
fi
}
check_dependency python3 python
check_dependency lsusb usbutils
# net-snmp is optional (only needed for network mode)
if [[ -n "${1:-}" ]] && ! command -v snmpwalk &>/dev/null; then
echo "Installing net-snmp (needed for network mode)..."
sudo pacman -S --noconfirm --needed net-snmp
fi
# ── Verify the Python module exists ──────────────────────────────────
if [[ ! -f "${PYTHON_PKG_DIR}/${BROTHER_MODULE}/check_brother_printer.py" ]]; then
echo "Error: Python module not found at ${PYTHON_PKG_DIR}/${BROTHER_MODULE}/" >&2
exit 1
fi
# ── Run (with sudo for USB access) ──────────────────────────────────
if [[ $EUID -ne 0 ]]; then
exec sudo bash -c "cd '$PYTHON_PKG_DIR' && python3 -m '$BROTHER_MODULE' $*"
fi
cd "$PYTHON_PKG_DIR"
exec python3 -m "$BROTHER_MODULE" "$@"