Esempio n. 1
0
 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)
Esempio n. 2
0
def print_pixel(colour, value_range, invert=1):
    global colour_range
    chars = [".", ".", "+", "*", "%", "#"]
    idx = lambda chars: (colour + 1) * (len(chars) - 1) / value_range
    if invert:
        idx = lambda chars, idx=idx: len(chars) - 1 - idx(chars)
    char = chars[idx(chars)]
    ansi_colour = palette[idx(palette)]
    ansi_print(char, ansi_colour, newline=False, flush=True)
Esempio n. 3
0
def print_pixel(colour, value_range, invert=1):
    global colour_range
    chars = [".", ".", "+", "*", "%", "#"]
    idx = lambda chars: (colour+1) * (len(chars) - 1) / value_range
    if invert:
        idx = lambda chars, idx=idx:len(chars) - 1 - idx(chars)
    char = chars[idx(chars)]
    ansi_colour = palette[idx(palette)]
    ansi_print(char, ansi_colour, newline=False, flush=True)
Esempio n. 4
0
 def __call__(self, msg):
     tty = self.isatty()
     flush = False
     newline = True
     keywords = []
     esc = []
     for kw in msg.keywords:
         color, supress = self.kw_to_color.get(kw, (None, False))
         if color:
             esc.extend(color)
         if not supress:
             keywords.append(kw)
     if 'start' in keywords:
         if tty:
             newline = False
             flush = True
             keywords.remove('start')
     elif 'done' in keywords:
         if tty:
             print >> sys.stderr
             return
     elif 'dot' in keywords:
         if tty:
             if self.fancy:
                 if not AnsiLog.wrote_dot:
                     self.mandelbrot_driver.reset()
                 self.mandelbrot_driver.dot()
             else:
                 ansi_print(".",
                            tuple(esc),
                            file=self.file,
                            newline=False,
                            flush=flush)
             AnsiLog.wrote_dot = True
             return
     if AnsiLog.wrote_dot:
         AnsiLog.wrote_dot = False
         sys.stderr.write("\n")
     esc = tuple(esc)
     for line in msg.content().splitlines():
         ansi_print("[%s] %s" % (":".join(keywords), line),
                    esc,
                    file=self.file,
                    newline=newline,
                    flush=flush)
Esempio n. 5
0
 def __call__(self, msg):
     tty = self.isatty()
     flush = False
     newline = True
     keywords = []
     esc = []
     for kw in msg.keywords:
         color, supress = self.kw_to_color.get(kw, (None, False))
         if color:
             esc.extend(color)
         if not supress:
             keywords.append(kw)
     if 'start' in keywords:
         if tty:
             newline = False
             flush = True
             keywords.remove('start')
     elif 'done' in keywords:
         if tty:
             print >> sys.stderr
             return
     elif 'dot' in keywords:
         if tty:
             if self.fancy:
                 if not AnsiLog.wrote_dot:
                     self.mandelbrot_driver.reset()
                 self.mandelbrot_driver.dot()
             else:
                 ansi_print(".", tuple(esc), file=self.file, newline=False, flush=flush)
             AnsiLog.wrote_dot = True
             return
     if AnsiLog.wrote_dot:
         AnsiLog.wrote_dot = False
         sys.stderr.write("\n")
     esc = tuple(esc)
     for line in msg.content().splitlines():
         ansi_print("[%s] %s" %(":".join(keywords), line), esc, 
                    file=self.file, newline=newline, flush=flush)
Esempio n. 6
0
def main():
    (options, args) = parser.parse_args()
    string = args[0]
    if options.ignorecase:
        string = string.lower()
    for x in curdir.visit('*.py', rec):
        try:
            s = x.read()
        except py.error.ENOENT:
            pass # whatever, probably broken link (ie emacs lock)
        searchs = s
        if options.ignorecase:
            searchs = s.lower()
        if s.find(string) != -1:
            lines = s.splitlines()
            if options.ignorecase:
                searchlines = s.lower().splitlines()
            else:
                searchlines = lines
            for i, (line, searchline) in enumerate(zip(lines, searchlines)): 
                indexes = find_indexes(searchline, string)
                if not indexes:
                    continue
                if not options.context:
                    sys.stdout.write("%s:%d: " %(x.relto(curdir), i+1))
                    last_index = 0
                    for index in indexes:
                        sys.stdout.write(line[last_index: index])
                        ansi_print(line[index: index+len(string)],
                                   file=sys.stdout, esc=31, newline=False)
                        last_index = index + len(string)
                    sys.stdout.write(line[last_index:] + "\n")
                else:
                    context = (options.context)/2
                    for count in range(max(0, i-context), min(len(lines) - 1, i+context+1)):
                        print "%s:%d:  %s" %(x.relto(curdir), count+1, lines[count].rstrip())
                    print "-" * terminal_width