コード例 #1
0
ファイル: ansi_mandelbrot.py プロジェクト: griels/pypy-sc
 def dot(self):
     """ Emits a colourful character. """
     x = c = 0
     try:
         x, y, c = self.gen.next()
         if x == 0:
             width = get_terminal_width()
             if width != self.width:
                 self.init()
     except StopIteration:
         kwargs = self.kwargs
         self.zoom_location += 1
         self.zoom_location %= len(self.zoom_locations)
         loc = self.zoom_locations[self.zoom_location]
         kwargs.update({
             "x_pos": loc[0],
             "y_pos": loc[1],
             "distance": loc[2]
         })
         self.colour_range = loc[3]
         #global colour_range
         #print colour_range, loc[2]
         #colour_range = None
         return self.restart()
     print_pixel(c, self.colour_range, self.invert)
     if x == self.width - 1:
         print >> sys.stderr
コード例 #2
0
ファイル: reporter.py プロジェクト: TheDunn/flex-pypy
 def report_ReceivedItemOutcome(self, event):
     host = event.host
     hostrepr = self._hostrepr(host)
     if event.outcome.passed:
         self.passed[host] += 1
         sys.stdout.write("%15s: PASSED  " % hostrepr)
     elif event.outcome.skipped:
         self.skipped_tests_outcome.append(event)
         self.skipped[host] += 1
         sys.stdout.write("%15s: SKIPPED " % hostrepr) 
     else:
         self.failed[host] += 1
         self.failed_tests_outcome.append(event)
         sys.stdout.write("%15s: " % hostrepr) 
         ansi_print("FAILED", esc=(31,1), newline=False, file=sys.stdout)
         sys.stdout.write("  ")
     # we should have printed 20 characters to this point
     itempath = ".".join(event.item.listnames()[1:-1])
     funname = event.item.listnames()[-1]
     lgt = get_terminal_width() - 20
     # mark the function name, to be sure
     to_display = len(itempath) + len(funname) + 1
     if to_display > lgt:
         sys.stdout.write("..." + itempath[to_display-lgt+4:])
     else:
         sys.stdout.write(itempath)
     sys.stdout.write(" ")
     ansi_print(funname, esc=32, file=sys.stdout)
コード例 #3
0
ファイル: test_terminal.py プロジェクト: TheDunn/flex-pypy
def test_terminal_width():
    """ Dummy test for get_terminal_width
    """
    assert get_terminal_width()
    try:
        import fcntl
    except ImportError:
        py.test.skip('fcntl not supported on this platform')
    def f(*args):
        raise ValueError
    ioctl = fcntl.ioctl
    fcntl.ioctl = f
    try:
        cols = os.environ.get('COLUMNS', None)
        os.environ['COLUMNS'] = '42'
        assert get_terminal_width() == 41
    finally:
        fcntl.ioctl = ioctl
        if cols:
            os.environ['COLUMNS'] = cols
コード例 #4
0
ファイル: test_terminal.py プロジェクト: neurobcn/plexnet
def test_terminal_width():
    """ Dummy test for get_terminal_width
    """
    assert get_terminal_width()
    try:
        import fcntl
    except ImportError:
        py.test.skip('fcntl not supported on this platform')

    def f(*args):
        raise ValueError

    ioctl = fcntl.ioctl
    fcntl.ioctl = f
    try:
        cols = os.environ.get('COLUMNS', None)
        os.environ['COLUMNS'] = '42'
        assert get_terminal_width() == 41
    finally:
        fcntl.ioctl = ioctl
        if cols:
            os.environ['COLUMNS'] = cols
コード例 #5
0
ファイル: ansi_mandelbrot.py プロジェクト: antoine1fr/pygirl
 def dot(self):
     """ Emits a colourful character. """
     x = c = 0
     try:
         x, y, c = self.gen.next()
         if x == 0:
             width = get_terminal_width()
             if width != self.width:
                 self.init()
     except StopIteration:
         kwargs = self.kwargs
         self.zoom_location += 1
         self.zoom_location %= len(self.zoom_locations)
         loc = self.zoom_locations[self.zoom_location]
         kwargs.update({"x_pos": loc[0], "y_pos": loc[1], "distance": loc[2]})
         self.colour_range = loc[3]
         #global colour_range
         #print colour_range, loc[2]
         #colour_range = None
         return self.restart()
     print_pixel(c, self.colour_range, self.invert)
     if x == self.width - 1:
         print >>sys.stderr
コード例 #6
0
ファイル: ansi_mandelbrot.py プロジェクト: griels/pypy-sc
 def init(self):
     self.width = get_terminal_width(
     ) or 80  # in some envs, the py lib doesnt default the width correctly
     self.mandelbrot = Mandelbrot(width=(self.width or 1), **self.kwargs)
     self.mandelbrot.init()
     self.gen = self.mandelbrot.generate()
コード例 #7
0
ファイル: out.py プロジェクト: TheDunn/flex-pypy
 def sep(self, sepchar, title=None):
     super(TerminalOut, self).sep(sepchar, title,
                                  terminal_helper.get_terminal_width())
コード例 #8
0
ファイル: ansi_mandelbrot.py プロジェクト: antoine1fr/pygirl
 def init(self):
     self.width = get_terminal_width() or 80 # in some envs, the py lib doesnt default the width correctly
     self.mandelbrot = Mandelbrot(width=(self.width or 1), **self.kwargs)
     self.mandelbrot.init()
     self.gen = self.mandelbrot.generate()
コード例 #9
0
ファイル: ansi_mandelbrot.py プロジェクト: TheDunn/flex-pypy
 def init(self):
     self.width = get_terminal_width()
     self.mandelbrot = Mandelbrot(width=(self.width or 1), **self.kwargs)
     self.mandelbrot.init()
     self.gen = self.mandelbrot.generate()