diff --git a/leapp/utils/output.py b/leapp/utils/output.py index e2da02bd5..b05c36e30 100644 --- a/leapp/utils/output.py +++ b/leapp/utils/output.py @@ -136,20 +136,6 @@ def _print_reports_summary(reports): print(' INFO severity reports: {:5}'.format(len(info))) -def _print_medium_and_high_reports(reports): - # The following imports are required to be here to avoid import loop problems - from leapp.reporting import Severity # noqa; pylint: disable=import-outside-toplevel - - high = _filter_reports(reports, Severity.HIGH) - medium = _filter_reports(reports, Severity.MEDIUM) - - if not high or not medium: - return - - print('HIGH and MEDIUM severity reports:') - _print_report_titles(high + medium) - - def report_info(context_id, report_paths, log_paths, answerfile=None, fail=False): report_paths = [report_paths] if not isinstance(report_paths, list) else report_paths log_paths = [log_paths] if not isinstance(report_paths, list) else log_paths @@ -160,11 +146,25 @@ def report_info(context_id, report_paths, log_paths, answerfile=None, fail=False sys.stdout.write("Debug output written to {path}\n".format(path=log_path)) if report_paths: - with pretty_block("REPORT", target=sys.stdout, color=Color.bold if fail else Color.green): - # The following imports are required to be here to avoid import loop problems - from leapp.utils.report import fetch_upgrade_report_messages # noqa; pylint: disable=import-outside-toplevel - reports = fetch_upgrade_report_messages(context_id) - _print_medium_and_high_reports(reports) + # The following imports are required to be here to avoid import loop problems + from leapp.reporting import Severity # noqa; pylint: disable=import-outside-toplevel + from leapp.utils.report import fetch_upgrade_report_messages # noqa; pylint: disable=import-outside-toplevel + reports = fetch_upgrade_report_messages(context_id) + + high = _filter_reports(reports, Severity.HIGH) + medium = _filter_reports(reports, Severity.MEDIUM) + + color = Color.green + if medium or high: + color = Color.yellow + if fail: + color = Color.bold + + with pretty_block("REPORT", target=sys.stdout, color=color): + if high or medium: + print('HIGH and MEDIUM severity reports:') + _print_report_titles(high + medium) + sys.stdout.write('\n') _print_reports_summary(reports)