How to use the colin.core.result.FailedCheckResult function in colin

To help you get started, we’ve selected a few colin examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github user-cont / colin / colin / core / checks / cmd.py View on Github external
"""
            except ConuException as ex:
                if str(ex).endswith("exit code 126") or str(ex).endswith("error: 127"):
                    return CheckResult(ok=False,
                                       description=self.description,
                                       message=self.message,
                                       reference_url=self.reference_url,
                                       check_name=self.name,
                                       logs=["exec: '{}': executable file not found in $PATH".format(
                                           self.cmd)])
                return FailedCheckResult(check=self,
                                         logs=[str(ex)])
            """
        except ColinException as ex:
            return FailedCheckResult(check=self,
                                     logs=[str(ex)])
        passed = True
        logs = ["Output:\n{}".format(output)]
        if self.substring is not None:
            substring_present = self.substring in output
            passed = passed and substring_present
            logs.append("{}: Substring '{}' is {}present in the output of the command '{}'." \
                        .format("ok" if substring_present else "nok",
                                self.substring,
                                "" if substring_present else "not ",
                                self.cmd))

        if self.expected_output is not None:
            expected_output = self.expected_output == output
            if expected_output:
                logs.append("ok: Output of the command '{}' "
github user-cont / colin / colin / core / check_runner.py View on Github external
try:
        for check in checks:
            logger.debug("Checking {}".format(check.name))
            try:
                _timeout = timeout or check.timeout or CHECK_TIMEOUT
                logger.debug("Check timeout: {}".format(_timeout))
                yield exit_after(_timeout)(check.check)(target)
            except TimeoutError as ex:
                logger.warning(
                    "The check hit the timeout: {}".format(_timeout))
                yield FailedCheckResult(check, logs=[str(ex)])
            except Exception as ex:
                tb = traceback.format_exc()
                logger.warning(
                    "There was an error while performing check: {}".format(tb))
                yield FailedCheckResult(check, logs=[str(ex)])
    finally:
        target.clean_up()
github user-cont / colin / colin / core / result.py View on Github external
def __init__(self, check, logs=None):
        super(FailedCheckResult, self) \
            .__init__(ok=False,
                      message=check.message,
                      description=check.description,
                      reference_url=check.reference_url,
                      check_name=check.name,
                      logs=logs or []
                      )