def report_errors(clazz, output, max_lines): """ Prints information about errors. The errors can be compilation errors or test failures. """ if COMPILE_ERR_PATC.search(output): # Compilation errors print error('Compilation errors:') for line in get_compilation_errors(output): print line else: # Test errors: search for the reports if clazz.endswith('Impl'): clazz = clazz[:-4] groups = (REPORT_DIR_PATC.match(line) for line in output.splitlines()) dirs = (clean_path(g.group(1)) for g in groups if g) reports = gen_find('*' + clazz + '*.txt', dirs.next()) lines = [line for line in open(reports.next())] if 0 < max_lines < len(lines): lines = lines[:max_lines] for line in lines: print line,
def gen_follow_all(file_pattern, top_dir, sleep_time=1, lastmod=time.time()): """ Generator that tracks all the files inside top_dir that match file_pattern. Yield's a file's full path each time it is modified. """ while True: files = search.gen_find(file_pattern, top_dir) mtimes = search.gen_mtimes(files) modified = (m for m in mtimes if m[search.MTIME] > lastmod) # TODO: make another generator that returns lists instead of one # file at a time. Try to optimize maven execution. max = lastmod for m in modified: if m[search.MTIME] > max: max = m[search.MTIME] yield m[search.PATH] lastmod = max time.sleep(sleep_time)