Add option to output failures only
This commit is contained in:
@@ -2,8 +2,9 @@ import json
|
||||
|
||||
|
||||
class CheckReporter:
|
||||
def __init__(self):
|
||||
def __init__(self, output_passes):
|
||||
self.checks = list()
|
||||
self.output_passes = output_passes
|
||||
|
||||
def append(self, check):
|
||||
self.checks.append(check)
|
||||
@@ -35,7 +36,7 @@ class JSONReporter(CheckReporter):
|
||||
list(
|
||||
map(
|
||||
lambda check: JSONReporter.__make_check_serialisable(check),
|
||||
self.checks,
|
||||
self.checks if self.output_passes else self.failed(),
|
||||
)
|
||||
),
|
||||
indent=4,
|
||||
@@ -45,6 +46,8 @@ class JSONReporter(CheckReporter):
|
||||
class DefaultReporter(CheckReporter):
|
||||
def append(self, check):
|
||||
super().append(check)
|
||||
if check.check_successful and not self.output_passes:
|
||||
return
|
||||
result = f"[{'PASS' if check.check_successful else 'FAIL'}] Check host {check.hostname}"
|
||||
if check.debug:
|
||||
result += f" - {check.debug}"
|
||||
|
||||
Reference in New Issue
Block a user