From 287688615250c9272ae3df1b138d289e524c96a4 Mon Sep 17 00:00:00 2001 From: Markus Lehtonen Date: Thu, 10 Jul 2014 11:26:19 +0300 Subject: [PATCH] log: fix auto colorizing for custom streams Check for existence of isatty() method in the stream object. Some custom streams (e.g. in nose) do not necessarily have this. Signed-off-by: Markus Lehtonen --- gbp/log.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gbp/log.py b/gbp/log.py index f21e2bb..6d2c0a6 100644 --- a/gbp/log.py +++ b/gbp/log.py @@ -75,7 +75,7 @@ class GbpStreamHandler(logging.StreamHandler): """Check if to print in color or not""" if self._color.is_on(): return True - elif self._color.is_auto(): + elif self._color.is_auto() and hasattr(self.stream, 'isatty'): in_emacs = (os.getenv("EMACS") and os.getenv("INSIDE_EMACS", "").endswith(",comint")) return self.stream.isatty() and not in_emacs -- 2.7.4