def show_status(self, stream=sys.stdout, verbose=0): """ Report the status of the workflows and the status of the different tasks on the specified stream. if not verbose, no full entry for works that are completed is printed. """ has_colours = stream_has_colours(stream) red = "red" if has_colours else None for i, work in enumerate(self): print(80*"=", file=stream) print("Workflow #%d: %s, Finalized=%s\n" % (i, work, work.finalized), file=stream) if verbose == 0 and work.finalized: continue table =PrettyTable([ "Task", "Status", "Queue-id", "Errors", "Warnings", "Comments", "MPI", "OMP", "Restarts", "Task-Class", "Run-Etime"]) tot_num_errors = 0 for task in work: task_name = os.path.basename(task.name) # Parse the events in the main output. report = task.get_event_report() events = map(str, 3*["N/A"]) if report is not None: events = map(str, [report.num_errors, report.num_warnings, report.num_comments]) events = list(events) cpu_info = list(map(str, [task.mpi_procs, task.omp_threads])) task_info = list(map(str, [task.num_restarts, task.__class__.__name__, task.run_etime()])) if task.status.is_critical: tot_num_errors += 1 task_name = colored(task_name, red) if has_colours: table.add_row([task_name, task.status.colored, str(task.queue_id)] + events + cpu_info + task_info) else: table.add_row([task_name, str(task.status), str(task.queue_id)] + events + cpu_info + task_info) # Print table and write colorized line with the total number of errors. print(table, file=stream) if tot_num_errors: cprint("Total number of errors: %d" % tot_num_errors, red, file=stream)
def __str__(self): #has_colours = stream_has_colours(stream) has_colours = True lines = [] app = lines.append app("Events found in %s\n" % self.filename) for i, event in enumerate(self): if has_colours: app("[%d] %s" % (i+1, colored(event.header, color=event.color))) app(indent(event.message, 4)) else: app("[%d] %s" % (i+1, str(event))) app("num_errors: %s, num_warnings: %s, num_comments: %s, completed: %s\n" % ( self.num_errors, self.num_warnings, self.num_comments, self.run_completed)) return "\n".join(lines)
def __str__(self): #has_colours = stream_has_colours(stream) has_colours = True lines = [] app = lines.append app("Events found in %s\n" % self.filename) for i, event in enumerate(self): if has_colours: app("[%d] %s" % (i + 1, colored(event.header, color=event.color))) app(indent(event.message, 4)) else: app("[%d] %s" % (i + 1, str(event))) app("num_errors: %s, num_warnings: %s, num_comments: %s, completed: %s\n" % (self.num_errors, self.num_warnings, self.num_comments, self.run_completed)) return "\n".join(lines)
def colored(self): """Return colorized text used to print the status if the stream supports it.""" return colored(str(self), **self.color_opts)
def text_str(node): return colored(str(node), color=node.status.color_opts["color"])