deploypkg.zsh: Various Updates

* Clean up colors/pacman.py for colorful output
* Fixes for the .local/bin move
* Use the $COLORS and $BIN variables from common.zsh

Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
This commit is contained in:
Anna Schumaker 2023-07-19 11:45:58 -04:00
parent 70dfceccef
commit 2e9699a52e
2 changed files with 9 additions and 14 deletions

View File

@ -1,17 +1,12 @@
#!/usr/bin/python
"""Add color and machine tags to remote pacman output."""
import termcolor
import re
import sys
prefix = sys.argv[1] if len(sys.argv) > 1 else None
pacman_colors = dict()
pacman_attrs = dict()
pacman_colors = {"==>": "green", "->": "blue"}
def add_color_attr(field, color, *attrs):
pacman_colors[field] = color
pacman_attrs[field] = attrs
add_color_attr("==>", "green", "bold")
add_color_attr("->", "blue", "bold")
for line in sys.stdin:
if prefix:
@ -19,8 +14,7 @@ for line in sys.stdin:
if "==>" in line or "->" in line:
for part in re.split(r'(\s+)', line):
color = pacman_colors.get(part, "white")
attrs = pacman_attrs.get(part, ["bold"])
termcolor.cprint(part, color, attrs=attrs, end="")
termcolor.cprint(part, color, attrs=["bold"], end="")
else:
print(line, end="")

View File

@ -1,5 +1,5 @@
#!/bin/zsh
colors="$HOME/bin/colors"
source common.zsh
if [ "$#" -lt 2 ]; then
echo "Usage: $0 /path/to/package {remote host, ...}"
@ -12,11 +12,12 @@ shift
function deploy_package() {
ssh $1 "mkdir -pv pkg" 2>&1 | sed -e "s/^/$2 /"
script -q -c "scp $pkg $1:pkg/ 2>&1" 2>&1 | sed -e "s/^/$2 /"
ssh $1 "sudo pacman --noconfirm -U pkg/$pkg" | python $colors/pacman.py $2
ssh $1 "sudo pacman --noconfirm -U pkg/$pkg" | python $COLORS/pacman.py $2
}
$HOME/bin/vm.zsh boot $*
tags=($(python $colors/vm.py $*))
$BIN/vm.zsh boot $*
tags=($(FORCE_COLOR=1 python $COLORS/vm.py $*))
for ((i=1; i<=$#; i++)); do
deploy_package ${@[i]} ${tags[i]} &
done