Skip to content

Commit

Permalink
squash! squash! Add reports summary to the output
Browse files Browse the repository at this point in the history
Use yellow if there are any HIGH or MEDIUM reports
  • Loading branch information
matejmatuska committed Mar 22, 2023
1 parent 8e28d98 commit a9832ce
Showing 1 changed file with 19 additions and 19 deletions.
38 changes: 19 additions & 19 deletions leapp/utils/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)

Expand Down

0 comments on commit a9832ce

Please sign in to comment.