summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Pokorný <jpokorny@redhat.com>2012-03-09 20:01:09 +0100
committerJan Pokorný <jpokorny@redhat.com>2012-03-09 20:01:09 +0100
commite3b4ba80be130bce4143151b4aa30bb44479c1c9 (patch)
tree17a48af203ee09b9810e1a8916a22ac2fa7e47f3
parentc34e04427b62c0e33d59be6064ca77824b69a8b9 (diff)
downloadwatch-bz-e3b4ba80be130bce4143151b4aa30bb44479c1c9.tar.gz
watch-bz-e3b4ba80be130bce4143151b4aa30bb44479c1c9.tar.xz
watch-bz-e3b4ba80be130bce4143151b4aa30bb44479c1c9.zip
remove unreasonable timer, abbreviations
Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
-rwxr-xr-xtable-data41
-rwxr-xr-xwatch-bz35
2 files changed, 53 insertions, 23 deletions
diff --git a/table-data b/table-data
index 2206e0e..e67e31a 100755
--- a/table-data
+++ b/table-data
@@ -4,6 +4,7 @@
from sys import stdin, argv
import cStringIO,operator
from threading import Timer, RLock
+from time import time
def indent(rows, hasHeader=False, headerChar='-', delim=' | ', justify='left',
separateRows=False, prefix='', postfix='', wrapfunc=lambda x:x):
@@ -79,28 +80,30 @@ def wrap_always(text, width):
if __name__ == '__main__':
- def timer(lock, data):
- with lock:
- data.append[False]
+ if len(argv) > 1:
+ sep = argv[1]
+ else:
+ sep = ','
+ timeout = 10.0
+ tries, max_tries = 0, 3
- lock = RLock()
- ret, data = True, [True]
+ while tries < max_tries:
+ ret, data = '', []
+ start = time()
- while ret and (not len(data) or data[-1] != ''): # EOF
- t = Timer(15, timer, args=(lock, data))
- while ret and data[-1]:
+ # until timeout or EOF (read may block pass the timeout!)
+ while (time() - start) < timeout:
ret = stdin.readline()
- #print "read", ret
- with lock:
- if not isinstance(data[-1], str):
- data = data[:-1]
- data.append(ret)
- t.cancel()
- #if not isinstance(data[-1], str):
- # data = data[:-1]
- sep = ','
- if len(argv) > 1:
- sep = argv[1]
+ if not ret:
+ break
+ data.append(ret)
+
+ if not ret:
+ tries += 1
+ else:
+ tries = 0
+ if not data:
+ continue
rows = [row.strip().split(sep) for row in data]
#print 'Without wrapping function\n'
diff --git a/watch-bz b/watch-bz
index cf221d4..aaf9667 100755
--- a/watch-bz
+++ b/watch-bz
@@ -17,7 +17,10 @@ STATUS=OPEN
REFRESH_INTERVAL=600 # [s], better not to drain bugzilla's power...
SEP=@@@
-OUTPUT_FMT="%{component}$SEP%{bug_id}$SEP%{priority}$SEP%{status}$SEP%{short_desc}"
+OUTPUT_FMT="%{component}$SEP%{bug_id}$SEP%{product}$SEP%{priority}$SEP%{status}$SEP%{flags}$SEP%{short_desc}"
+#OUTPUT_FMT="%{component}$SEP%{bug_id}$SEP%{product}$SEP%{priority}$SEP%{status}$SEP%{short_desc}"
+
+WIDTH=$(( $(stty size | cut -d' ' -f2) - 1 ))
if [ $# -ge 1 ]; then
if [[ "$1" = -* ]]; then
@@ -31,9 +34,33 @@ fi
watch -t --interval $REFRESH_INTERVAL \
"$BUGZILLA query -c $COMPONENT -t $STATUS --outputformat $OUTPUT_FMT \
- | table-data $SEP \
| sed -u \
- -e 's/urgent/URGENT/' \
- -e 's/important/IMPORTANT/'"
+ -e \"s/${SEP}Red Hat Enterprise Linux /${SEP}EL/\" \
+ -e \"s/${SEP}Fedora/${SEP}fed/\" \
+ -e \"s/${SEP}NEW/${SEP}N/\" \
+ -e \"s/${SEP}ASSIGNED/${SEP}A/\" \
+ -e \"s/${SEP}POST/${SEP}P/\" \
+ -e \"s/${SEP}MODIFIED/${SEP}M/\" \
+ -e \"s/${SEP}ON_QA/${SEP}Q/\" \
+ -e \"s/${SEP}ON_DEV/${SEP}D/\" \
+ -e \"s/${SEP}VERIFIED/${SEP}V/\" \
+ -e \"s/${SEP}RELEASE_PENDING/${SEP}R/\" \
+ -e \"s/${SEP}CLOSED/${SEP}C/\" \
+ -e \"s/${SEP}urgent/${SEP}!!!/\" \
+ -e \"s/${SEP}high/${SEP}!!/\" \
+ -e \"s/${SEP}medium/${SEP} ! /\" \
+ -e \"s/${SEP}low/${SEP} ~ /\" \
+ -e \"s/${SEP}unspecified/${SEP} ? /\" \
+ -e \"s/qa_ack/QA/\" \
+ -e \"s/pm_ack/PM/\" \
+ -e \"s/devel_ack/D/\" \
+ -e \"s/needinfo/I/\" \
+ -e \"s/exception/E/\" \
+ -e \"s/blocker/BL/\" \
+ -e \"s/requires_release_note/RN/\" \
+ -e \"s/rhel-//\" \
+ -e \"s/None//\" \
+ | tee out1.txt | table-data $SEP \
+ | cut -c-$WIDTH | tee out.txt"
# todo: colours for priorities (rhbz#801626)
#-e 's/\(urgent\)/\^\[\[31m\1\^\[\[0m/' \