def long_message(self): out = StringIO() out.write(self._long_message if self._long_message else '') if (self.module, self.name) in ChildError.build_errors: # The error happened in some external executed process. Show # the build log with errors highlighted. if self.build_log: errors, warnings = parse_log_events(self.build_log) nerr = len(errors) if nerr > 0: if nerr == 1: out.write("\n1 error found in build log:\n") else: out.write("\n%d errors found in build log:\n" % nerr) out.write(make_log_context(errors)) else: # The error happened in in the Python code, so try to show # some context from the Package itself. if self.context: out.write('\n') out.write('\n'.join(self.context)) out.write('\n') if out.getvalue(): out.write('\n') if self.build_log: out.write('See build log for details:\n') out.write(' %s' % self.build_log) return out.getvalue()
def long_message(self): out = StringIO() out.write(self._long_message if self._long_message else '') if (self.module, self.name) in ChildError.build_errors: # The error happened in some external executed process. Show # the build log with errors or warnings highlighted. if self.build_log and os.path.exists(self.build_log): errors, warnings = parse_log_events(self.build_log) nerr = len(errors) nwar = len(warnings) if nerr > 0: # If errors are found, only display errors out.write("\n%s found in build log:\n" % plural(nerr, 'error')) out.write(make_log_context(errors)) elif nwar > 0: # If no errors are found but warnings are, display warnings out.write("\n%s found in build log:\n" % plural(nwar, 'warning')) out.write(make_log_context(warnings)) else: # The error happened in in the Python code, so try to show # some context from the Package itself. if self.context: out.write('\n') out.write('\n'.join(self.context)) out.write('\n') if out.getvalue(): out.write('\n') if self.build_log and os.path.exists(self.build_log): out.write('See build log for details:\n') out.write(' %s\n' % self.build_log) return out.getvalue()
def long_message(self): out = StringIO() out.write(self._long_message if self._long_message else '') if (self.module, self.name) in ChildError.build_errors: # The error happened in some external executed process. Show # the build log with errors or warnings highlighted. if self.build_log and os.path.exists(self.build_log): errors, warnings = parse_log_events(self.build_log) nerr = len(errors) nwar = len(warnings) if nerr > 0: # If errors are found, only display errors out.write( "\n%s found in build log:\n" % plural(nerr, 'error')) out.write(make_log_context(errors)) elif nwar > 0: # If no errors are found but warnings are, display warnings out.write( "\n%s found in build log:\n" % plural(nwar, 'warning')) out.write(make_log_context(warnings)) else: # The error happened in in the Python code, so try to show # some context from the Package itself. if self.context: out.write('\n') out.write('\n'.join(self.context)) out.write('\n') if out.getvalue(): out.write('\n') if self.build_log and os.path.exists(self.build_log): out.write('See build log for details:\n') out.write(' %s' % self.build_log) return out.getvalue()
def write_log_summary(out, log_type, log, last=None): errors, warnings = parse_log_events(log) nerr = len(errors) nwar = len(warnings) if nerr > 0: if last and nerr > last: errors = errors[-last:] nerr = last # If errors are found, only display errors out.write("\n%s found in %s log:\n" % (plural(nerr, 'error'), log_type)) out.write(make_log_context(errors)) elif nwar > 0: if last and nwar > last: warnings = warnings[-last:] nwar = last # If no errors are found but warnings are, display warnings out.write("\n%s found in %s log:\n" % (plural(nwar, 'warning'), log_type)) out.write(make_log_context(warnings))
def log_parse(parser, args): input = args.file if args.file == '-': input = sys.stdin errors, warnings = parse_log_events( input, args.context, args.jobs, args.profile) if args.profile: return types = [s.strip() for s in args.show.split(',')] for e in types: if e not in event_types: tty.die('Invalid event type: %s' % e) events = [] if 'errors' in types: events.extend(errors) print('%d errors' % len(errors)) if 'warnings' in types: events.extend(warnings) print('%d warnings' % len(warnings)) print(make_log_context(events, args.width))
def log_parse(parser, args): input = args.file if args.file == '-': input = sys.stdin errors, warnings = parse_log_events( input, args.context, args.jobs, args.profile) if args.profile: return types = [s.strip() for s in args.show.split(',')] for e in types: if e not in event_types: tty.die('Invalid event type: %s' % e) events = [] if 'errors' in types: events.extend(errors) print('%d errors' % len(errors)) if 'warnings' in types: events.extend(warnings) print('%d warnings' % len(warnings)) print(make_log_context(events, args.width))