diff options
author | Todd Gamblin <tgamblin@llnl.gov> | 2014-12-29 01:05:21 -0800 |
---|---|---|
committer | Todd Gamblin <tgamblin@llnl.gov> | 2014-12-29 01:05:21 -0800 |
commit | a6e00f6086467eda633e099d3ed7696bd85184e7 (patch) | |
tree | 4dd3f2fff2fd8d5778a43275922601543f63c297 /lib/spack/llnl/util/tty/color.py | |
parent | 6ffcdc1166642a70978a8631364aa8fd93560b62 (diff) | |
download | spack-a6e00f6086467eda633e099d3ed7696bd85184e7.tar.gz spack-a6e00f6086467eda633e099d3ed7696bd85184e7.tar.bz2 spack-a6e00f6086467eda633e099d3ed7696bd85184e7.tar.xz spack-a6e00f6086467eda633e099d3ed7696bd85184e7.zip |
Fix ColorStream
Diffstat (limited to 'lib/spack/llnl/util/tty/color.py')
-rw-r--r-- | lib/spack/llnl/util/tty/color.py | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/lib/spack/llnl/util/tty/color.py b/lib/spack/llnl/util/tty/color.py index 598e9d44f5..81688d7f14 100644 --- a/lib/spack/llnl/util/tty/color.py +++ b/lib/spack/llnl/util/tty/color.py @@ -177,17 +177,20 @@ def cescape(string): class ColorStream(object): def __init__(self, stream, color=None): - self.__class__ = type(stream.__class__.__name__, - (self.__class__, stream.__class__), {}) - self.__dict__ = stream.__dict__ - self.color = color - self.stream = stream + self._stream = stream + self._color = color def write(self, string, **kwargs): - if kwargs.get('raw', False): - super(ColorStream, self).write(string) - else: - cwrite(string, self.stream, self.color) + raw = kwargs.get('raw', False) + raw_write = getattr(self._stream, 'write') + + color = self._color + if self._color is None: + if raw: + color=True + else: + color = self._stream.isatty() + raw_write(colorize(string, color=color)) def writelines(self, sequence, **kwargs): raw = kwargs.get('raw', False) |