[pypy-svn] r41244 - pypy/dist/pypy/tool
xoraxax at codespeak.net
xoraxax at codespeak.net
Sat Mar 24 18:09:30 CET 2007
Author: xoraxax
Date: Sat Mar 24 18:09:29 2007
New Revision: 41244
Modified:
pypy/dist/pypy/tool/ansi_mandelbrot.py
pypy/dist/pypy/tool/ansi_print.py
Log:
Make the mandelbrot driver invocation more robust and check for isatty early.
Modified: pypy/dist/pypy/tool/ansi_mandelbrot.py
==============================================================================
--- pypy/dist/pypy/tool/ansi_mandelbrot.py (original)
+++ pypy/dist/pypy/tool/ansi_mandelbrot.py Sat Mar 24 18:09:29 2007
@@ -110,8 +110,8 @@
self.init()
def init(self):
- self.width = get_terminal_width() or 1
- self.mandelbrot = Mandelbrot(width=self.width, **self.kwargs)
+ self.width = get_terminal_width()
+ self.mandelbrot = Mandelbrot(width=(self.width or 1), **self.kwargs)
self.mandelbrot.init()
self.gen = self.mandelbrot.generate()
Modified: pypy/dist/pypy/tool/ansi_print.py
==============================================================================
--- pypy/dist/pypy/tool/ansi_print.py (original)
+++ pypy/dist/pypy/tool/ansi_print.py Sat Mar 24 18:09:29 2007
@@ -25,13 +25,17 @@
self.kw_to_color = self.KW_TO_COLOR.copy()
self.kw_to_color.update(kw_to_color)
self.file = file
- self.mandelbrot_driver = Driver()
+ self.fancy = True
+ self.isatty = getattr(sys.stderr, 'isatty', lambda: False)
+ if self.fancy and self.isatty():
+ self.mandelbrot_driver = Driver()
+ else:
+ self.mandelbrot_driver = None
def __call__(self, msg):
- tty = getattr(sys.stderr, 'isatty', lambda: False)()
+ tty = self.isatty()
flush = False
newline = True
- fancy = True
keywords = []
esc = []
for kw in msg.keywords:
@@ -51,7 +55,7 @@
return
elif 'dot' in keywords:
if tty:
- if fancy:
+ if self.fancy:
if not AnsiLog.wrote_dot:
self.mandelbrot_driver.reset()
self.mandelbrot_driver.dot()
More information about the Pypy-commit
mailing list