Skip to content

Commit b30dba1

Browse files
committed
fixup! Add an ERROR report group
1 parent 0fb569e commit b30dba1

File tree

3 files changed

+18
-13
lines changed

3 files changed

+18
-13
lines changed

leapp/reporting/__init__.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ class Groups(BaseListPrimitive):
127127
INHIBITOR = 'inhibitor'
128128
# This is used for framework error reports
129129
# Reports indicating failure in actors should use the FAILURE group
130-
ERROR = 'error'
130+
_ERROR = 'error'
131131
FAILURE = 'failure'
132132
ACCESSIBILITY = 'accessibility'
133133
AUTHENTICATION = 'authentication'
@@ -189,7 +189,11 @@ def __init__(self, *args, **kwargs):
189189

190190
# To allow backwards-compatibility with previous report-schema
191191
# Groups that match _DEPRECATION_FLAGS will be shown as flags, the rest as tags
192-
_DEPRECATION_FLAGS = [Groups.INHIBITOR, Groups.FAILURE, Groups.ERROR]
192+
_DEPRECATION_FLAGS = [Groups.INHIBITOR, Groups.FAILURE]
193+
194+
# NOTE(mmatuska): this a temporary solution until Groups._ERROR in the json report-schema
195+
# is altered to account for this addition of Groups_ERROR
196+
_UPCOMING_DEPRECATION_FLAGS = [Groups._ERROR]
193197

194198

195199
class Key(BasePrimitive):
@@ -383,9 +387,9 @@ def _create_report_object(entries):
383387
entry.apply(report)
384388

385389
if Groups.INHIBITOR in report.get('groups', []):
386-
if Groups.ERROR in report.get('groups', []):
390+
if Groups._ERROR in report.get('groups', []):
387391
# *error != inhibitor*
388-
msg = ('Only one of Groups.ERROR and Groups.INHIBITOR can be set at once.'
392+
msg = ('Only one of Groups._ERROR and Groups.INHIBITOR can be set at once.'
389393
' Maybe you were looking for Groups.FAILURE?')
390394
raise ValueError(msg)
391395

@@ -394,9 +398,9 @@ def _create_report_object(entries):
394398
# Currently we know that 'flags' does not exist otherwise so it's
395399
# safe to just set it
396400
report['flags'] = [Groups.INHIBITOR]
397-
if Groups.ERROR in report.get('groups', []):
401+
if Groups._ERROR in report.get('groups', []):
398402
# see above for explanation
399-
report['flags'] = [Groups.ERROR]
403+
report['flags'] = [Groups._ERROR]
400404

401405
return Report(report=report)
402406

@@ -449,7 +453,7 @@ def create_report_from_error(error_dict):
449453
Summary(error.details or ""),
450454
Severity('high'),
451455
Audience('sysadmin'),
452-
Groups([Groups.ERROR])
456+
Groups([Groups._ERROR])
453457
]
454458
report = _create_report_object(entries)
455459
return json.loads(report.dump()['report'])

leapp/utils/output.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ def _filter_reports(reports, severity=None, has_flag=None):
116116
from leapp.utils.report import has_flag_group # noqa; pylint: disable=import-outside-toplevel
117117

118118
def is_ordinary_report(report):
119-
return not has_flag_group(report, Groups.ERROR) and not has_flag_group(report, Groups.INHIBITOR)
119+
return not has_flag_group(report, Groups._ERROR) and not has_flag_group(report, Groups.INHIBITOR)
120120

121121
result = reports
122122
if has_flag is False:
@@ -133,7 +133,7 @@ def _print_reports_summary(reports):
133133
# The following imports are required to be here to avoid import loop problems
134134
from leapp.reporting import Groups, Severity # noqa; pylint: disable=import-outside-toplevel
135135

136-
errors = _filter_reports(reports, has_flag=Groups.ERROR)
136+
errors = _filter_reports(reports, has_flag=Groups._ERROR)
137137
inhibitors = _filter_reports(reports, has_flag=Groups.INHIBITOR)
138138

139139
ordinary = _filter_reports(reports, has_flag=False)

leapp/utils/report.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
from leapp.reporting import (
99
_DEPRECATION_FLAGS,
10+
_UPCOMING_DEPRECATION_FLAGS,
1011
Groups,
1112
Remediation,
1213
Severity,
@@ -107,7 +108,7 @@ def has_flag_group(message, group):
107108

108109

109110
def importance(message):
110-
if has_flag_group(message, Groups.ERROR):
111+
if has_flag_group(message, Groups._ERROR):
111112
return -1
112113
if has_flag_group(message, Groups.INHIBITOR):
113114
return 0
@@ -121,7 +122,7 @@ def generate_report_file(messages_to_report, context, path, report_schema='1.1.0
121122
with io.open(path, 'w', encoding='utf-8') as f:
122123
for message in sorted(messages_to_report, key=importance):
123124
flag = ''
124-
if has_flag_group(message, Groups.ERROR):
125+
if has_flag_group(message, Groups._ERROR):
125126
flag = '(error)'
126127
elif has_flag_group(message, Groups.INHIBITOR):
127128
flag = '(inhibitor)'
@@ -158,8 +159,8 @@ def generate_report_file(messages_to_report, context, path, report_schema='1.1.0
158159
messages_to_report = list(messages_to_report)
159160
for msg in messages_to_report:
160161
groups = msg.pop('groups', [])
161-
msg['flags'] = [g for g in groups if g in _DEPRECATION_FLAGS]
162-
msg['tags'] = [g for g in groups if g not in _DEPRECATION_FLAGS]
162+
msg['flags'] = [g for g in groups if g in _DEPRECATION_FLAGS and g not in _UPCOMING_DEPRECATION_FLAGS]
163+
msg['tags'] = [g for g in groups if g not in _DEPRECATION_FLAGS and g not in _UPCOMING_DEPRECATION_FLAGS]
163164
if report_schema_tuple == (1, 2, 0):
164165
# DEPRECATED: flags, tags
165166
# NOTE(pstodulk): This is a temporary solution to ensure that

0 commit comments

Comments
 (0)