diff options
author | Rafael H. Schloming <rhs@apache.org> | 2009-08-12 20:02:47 +0000 |
---|---|---|
committer | Rafael H. Schloming <rhs@apache.org> | 2009-08-12 20:02:47 +0000 |
commit | bcf296290a524c0d775bc9c741d212ba6aa62d40 (patch) | |
tree | 69e10ff0965337f3468475a15226eb1dceb55593 | |
parent | 77e7a30b2c5d08465664b86c806cd2c0fa0f5e37 (diff) | |
download | qpid-python-bcf296290a524c0d775bc9c741d212ba6aa62d40.tar.gz |
check the TERM environment variable as well as isatty to determine how smart the terminal is
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@803687 13f79535-47bb-0310-9956-ffa450edef68
-rwxr-xr-x | qpid/python/qpid-python-test | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/qpid/python/qpid-python-test b/qpid/python/qpid-python-test index ca6bec00fb..22063185b2 100755 --- a/qpid/python/qpid-python-test +++ b/qpid/python/qpid-python-test @@ -123,8 +123,11 @@ def is_included(path): return True return False +def is_smart(): + return sys.stdout.isatty() and os.environ.get("TERM", "dumb") != "dumb" + def width(): - if sys.stdout.isatty(): + if is_smart(): s = struct.pack("HHHH", 0, 0, 0, 0) fd_stdout = sys.stdout.fileno() x = fcntl.ioctl(fd_stdout, termios.TIOCGWINSZ, s) @@ -155,7 +158,7 @@ KEYWORDS = {"pass": (32,), "ignored": (33,), "selected": (34,)} -COLORIZE = sys.stdout.isatty() +COLORIZE = is_smart() def colorize_word(word, text=None): if text is None: |