2018-10-03 11:05:42 +02:00
|
|
|
class AbstractChecker(object):
|
|
|
|
"""
|
|
|
|
Our blueprint for checks
|
|
|
|
"""
|
|
|
|
|
|
|
|
def __init__(self, config, previous_results=None):
|
|
|
|
self._config = config
|
|
|
|
|
|
|
|
# A dictionary of results from previous checkers.
|
|
|
|
# Key is the name of the checker that has generated the result.
|
|
|
|
self._previous_results = previous_results
|
|
|
|
|
2018-11-28 23:46:40 +01:00
|
|
|
def depends_on_results(self):
|
|
|
|
"""
|
|
|
|
Should return the name(s) of checks this one depends on.
|
|
|
|
Empty list means this check has no prerequisites.
|
|
|
|
"""
|
|
|
|
return []
|
|
|
|
|
2018-10-03 11:05:42 +02:00
|
|
|
def run(self):
|
|
|
|
"""Executes the check routine, returns result dict"""
|
|
|
|
raise NotImplementedError()
|
2018-11-28 23:46:40 +01:00
|
|
|
|
2021-11-11 20:15:43 +01:00
|
|
|
def post_hook(self, result):
|
|
|
|
"""
|
|
|
|
Optional function to execute after run(). Can be used to post-process
|
|
|
|
results data. Should be defined by the implementing checker.
|
|
|
|
|
|
|
|
Params:
|
|
|
|
result: Result data from the run() function.
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
Dict: Modified results data
|
|
|
|
None: Means that nothing has been done, so should be ignored.
|
|
|
|
"""
|
|
|
|
return None
|
|
|
|
|
2018-10-03 11:05:42 +02:00
|
|
|
@property
|
|
|
|
def config(self):
|
|
|
|
return self._config
|
|
|
|
|
|
|
|
@property
|
|
|
|
def previous_results(self):
|
|
|
|
return self._previous_results
|