From 2415c8a37d4a06ca7f474909d21313e20f22f67d Mon Sep 17 00:00:00 2001 From: Jan Pokorný Date: Sun, 11 Mar 2012 16:35:46 +0100 Subject: fix issues, remove debug outputs, support dotfile MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jan Pokorný --- watch-bz | 44 ++++++++++++++++++++++++++++++++------------ 1 file changed, 32 insertions(+), 12 deletions(-) diff --git a/watch-bz b/watch-bz index 2655b68..7aca6fa 100755 --- a/watch-bz +++ b/watch-bz @@ -3,21 +3,31 @@ # jpokorny@redhat.com (will be pleased to know about further enhancements) # usage: -# 1. git clone git://git.fedorahosted.org/git/python-bugzilla -# 2. edit BUGZILLA_ROOT below -# 3. also edit COMPONENT as per example (or pass such string as a 1st argument) -# 4. optionally use "bugzilla login username password" to generate auth. cookie - -BUGZILLA_ROOT=~/wrkspc/python-bugzilla -BUGZILLA=${BUGZILLA_ROOT}/bin/bugzilla -export PYTHONPATH=$BUGZILLA_ROOT:$PYTHONPATH +# 1. optionally git clone git://git.fedorahosted.org/git/python-bugzilla +# (system-wide can also be used) +# 2. open ~/.watchbzrc for editing +# - set BUGZILLA_ROOT when using cloned python-bugzilla +# - optionally set STATUS and COMPONENT as per example +# (or pass such string as a 1st argument) +# - optionally set BZUSER to avoid the need to login manually before +# the "watch session"; you can set BZPASSWORD as well but be careful! +BUGZILLA=$(which bugzilla 2>/dev/null) +# example defaults, modify via ~/.watchbzrc COMPONENT=luci,ricci,clustermon,conga,sunzi STATUS=OPEN - REFRESH_INTERVAL=600 # [s], better not to drain bugzilla's power... -SEP=@@@ +[ -f ~/.watchbzrc ] && source ~/.watchbzrc + +if [ -z "$BUGZILLA" ]; then + # BUGZILLA_ROOT (path to local repo) should rather be set in ~/.watchbzrc + BUGZILLA="${BUGZILLA_ROOT}/bin/bugzilla" + export PYTHONPATH="${BUGZILLA_ROOT}:${PYTHONPATH}" +fi + +# hardcoded for now (note the SEP - OUTPUT_FMT relationship) +SEP=@@@ WIDTH=$(( $(stty size | cut -d' ' -f2) - 1 )) if [ $# -ge 1 ]; then @@ -30,6 +40,7 @@ if [ $# -ge 1 ]; then fi fi +# omit component if only single one queried echo $COMPONENT | grep -q ',' if [ $? -eq 0 ]; then OUTPUT_FMT="%{component}$SEP%{bug_id}$SEP%{product}$SEP%{priority}$SEP%{status}$SEP%{flags}$SEP%{short_desc}" @@ -37,6 +48,16 @@ else OUTPUT_FMT="%{bug_id}$SEP%{product}$SEP%{priority}$SEP%{status}$SEP%{flags}$SEP%{short_desc}" fi +# login when available +if [ -n "$BZUSER" ]; then + "$BUGZILLA" login "$BZUSER" $BZPASSWORD + if [ $? -ne 0 ]; then + echo "Cannot log in" + exit 2 + fi +fi + +#sh -c \ watch -t --interval $REFRESH_INTERVAL \ "$BUGZILLA query -c $COMPONENT -t $STATUS --outputformat $OUTPUT_FMT \ | sed -u \ @@ -65,7 +86,6 @@ watch -t --interval $REFRESH_INTERVAL \ -e \"s/requires_release_note/RN/\" \ -e \"s/rhel-//\" \ -e \"s/None//\" \ - | tee out1.txt | table-data $SEP \ - | cut -c-$WIDTH | tee out.txt" + | ./table-data $SEP | cut -c-$WIDTH" # todo: colours for priorities (rhbz#801626) #-e 's/\(urgent\)/\^\[\[31m\1\^\[\[0m/' \ -- cgit