Rewrite BMS skill from bash to Python

This commit is contained in:
Steve W
2026-04-08 02:19:50 +00:00
parent 568b825e11
commit 59d6e5ba3a
17 changed files with 938 additions and 1286 deletions

View File

@@ -1,33 +1,6 @@
#!/usr/bin/env bash
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# Get token from bms-auth.sh
if ! token=$(bash "${SCRIPT_DIR}/bms-auth.sh" get-token 2>/dev/null); then
echo "Error: Failed to retrieve BMS token" >&2
exit 1
fi
case "${1}" in
--account|--account=*)
account_id="${1#*=}" || account_id="${2}"
shift $(($# > 1 ? 2 : 1))
;;
*)
echo "Usage: $0 --account <id>" >&2
exit 1
;;
esac
curl --silent --show-error --fail \
-H "Authorization: Bearer $token" \
"https://api.bms.kaseya.com/v2/crm/accounts/${account_id}/locations/lookup" | \
jq -r '.result[]? // .[]' | \
while IFS= read -r line; do
id=$(echo "$line" | jq -r '.Id')
name=$(echo "$line" | jq -r '.Name')
printf "%-10s %-40s\n" "$id" "$name"
done
exit 0
REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
export PYTHONPATH="${REPO_ROOT}/src${PYTHONPATH:+:$PYTHONPATH}"
exec python3 -m openclaw_bms locations "$@"