From 2e9699a52e9633476fb3ffa3f819203fe5727a67 Mon Sep 17 00:00:00 2001 From: Anna Schumaker Date: Wed, 19 Jul 2023 11:45:58 -0400 Subject: [PATCH] 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 --- colors/pacman.py | 14 ++++---------- deploypkg.zsh | 9 +++++---- 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/colors/pacman.py b/colors/pacman.py index d39718b..9c6d2e1 100644 --- a/colors/pacman.py +++ b/colors/pacman.py @@ -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="") diff --git a/deploypkg.zsh b/deploypkg.zsh index f5a70b3..1bd85e3 100755 --- a/deploypkg.zsh +++ b/deploypkg.zsh @@ -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