diff options
author | Guido Günther <agx@sigxcpu.org> | 2011-02-08 08:29:01 +0100 |
---|---|---|
committer | Guido Günther <agx@sigxcpu.org> | 2011-02-08 08:31:44 +0100 |
commit | b9acbf981726b8af04d2a0b721f2cdd86755e09b (patch) | |
tree | 0881e1359f4b5fb6ea52cb21abccc2f53e126bd7 /gbp | |
parent | 7f00d3967cf5f75b7cf1e6469781094e61842d9b (diff) |
logging: don't use color inside Emacs's comint shell
Closes: #612384
Diffstat (limited to 'gbp')
-rw-r--r-- | gbp/log.py | 16 |
1 files changed, 13 insertions, 3 deletions
@@ -17,6 +17,7 @@ # """Simple colored logging classes""" +import os import sys import gbp.tristate @@ -50,6 +51,17 @@ class Logger(object): def set_level(self, level): self.level = level + def _is_tty(self): + if (os.getenv("EMACS") and + os.getenv("INSIDE_EMACS", "").endswith(",comint")): + return False + + if (sys.stderr.isatty() and + sys.stdout.isatty()): + return True + + return False + def set_color(self, color): if type(color) == type(True): self.color = color @@ -57,9 +69,7 @@ class Logger(object): if color.is_on(): self.color = True elif color.is_auto(): - if (sys.stderr.isatty() and - sys.stdout.isatty()): - self.color = True + self.color = self._is_tty() else: self.color = False |