Exemplo n.º 1
0
 def validate(self, input_data, ctx: Context) -> ValidationResult:
     if input_data is None or \
             not input_data.docker_ok or \
             not input_data.auth_ok:
         return ValidationResult(input_data, Status.NOT_FOUND)
     else:
         return ValidationResult(input_data, Status.OK)
Exemplo n.º 2
0
    def validate(self, input_data: XcodeInfo,
                 ctx: Context) -> ValidationResult:
        if input_data is None:
            ctx.logger.warn("Xcode not installed!")
            return ValidationResult(input_data, Status.NOT_FOUND)

        else:
            ctx.logger.debug("Detected Xcode path '{}'".format(
                input_data.path))
            return ValidationResult(input_data, Status.OK)
Exemplo n.º 3
0
    def validate(self, input_data: DockerInfo,
                 ctx: Context) -> ValidationResult:
        if input_data is None:
            return ValidationResult(input_data, Status.ERROR)

        if not input_data.d4m_installed:
            ctx.logger.warn("Docker Desktop not installed!")
            return ValidationResult(input_data, Status.NOT_FOUND)

        return ValidationResult(input_data, Status.OK)
Exemplo n.º 4
0
    def validate(self, input_data: BazelInfo,
                 ctx: Context) -> ValidationResult:
        if input_data is None:
            ctx.logger.warn("Bazel not installed!")
            return ValidationResult(input_data, Status.NOT_FOUND)

        if input_data.bazelisk:
            return ValidationResult(input_data, Status.OK)

        ctx.logger.warn("Bazel upgrade required")
        return ValidationResult(input_data, Status.UPGRADE_REQUIRED)
Exemplo n.º 5
0
    def validate(self, input_data: PythonInfo,
                 ctx: Context) -> ValidationResult:
        if input_data is None:
            ctx.logger.warn("Python not installed!")
            return ValidationResult(input_data, Status.NOT_FOUND)

        if int(self.expected_ver.major) > int(input_data.version.major) \
                or int(self.expected_ver.minor) > int(input_data.version.minor):
            ctx.logger.warn(
                "Python upgrade required! Expected: {}, actual: {}".format(
                    self.expected_ver, input_data.version))
            return ValidationResult(input_data, Status.UPGRADE_REQUIRED)
        else:
            return ValidationResult(input_data, Status.OK)
Exemplo n.º 6
0
    def validate(self, input_data: DiskInfo, ctx: Context) -> ValidationResult:
        if input_data is None:
            ctx.logger.error("No disk space info!")
            return ValidationResult(input_data, Status.ERROR)

        free_ratio = input_data.free / input_data.total
        if free_ratio < 0.1:
            free_percent = int(free_ratio * 100)
            ctx.logger.warn(
                "Low disk space on filesystem '{}' ({}% free)".format(
                    input_data.filesystem, free_percent))

            return ValidationResult(input_data, Status.WARNING)

        return ValidationResult(input_data, Status.OK)
Exemplo n.º 7
0
    def validate(self, input_data: PythonInfo,
                 ctx: Context) -> ValidationResult:
        if input_data is None:
            ctx.logger.warn("Python not installed!")
            return ValidationResult(input_data, Status.NOT_FOUND)

        if self.expected_ver != input_data.version:
            ctx.logger.warn(
                "Incompatible Python version! Expected: {}, actual: {}".format(
                    self.expected_ver, input_data.version))

            return ValidationResult(input_data, Status.NOT_FOUND)

        else:
            return ValidationResult(input_data, Status.OK)
Exemplo n.º 8
0
    def validate(self, input_data, ctx: Context) -> ValidationResult:
        if input_data is None:
            ctx.logger.error("Network connectivity check returned no data!")
            return ValidationResult(input_data, Status.ERROR)

        for check in input_data:
            if check.ok:
                if check.time > 2:
                    ctx.logger.warn(
                        "Network connectivity check to {} took {} seconds".format(check.address, check.time)
                    )
            else:
                ctx.logger.warn(
                    "Network connectivity check to {} failed! Error: {}".format(check.address, check.message)
                )

        return ValidationResult(input_data, Status.OK)
Exemplo n.º 9
0
    def validate(self, input_data: HardwareInfo,
                 ctx: Context) -> ValidationResult:
        if input_data is None:
            return ValidationResult(input_data, Status.ERROR)

        minimum_cpu_count = ctx.config["hardware"]["minimum_cpu_count"]
        if input_data.cpu_count < minimum_cpu_count:
            ctx.logger.warn(
                "If you are using Bazel regularly, {} CPUs is suboptimal".
                format(input_data.cpu_count))

        minimum_total_ram_gb = ctx.config["hardware"]["minimum_total_ram_gb"]
        if input_data.total_ram < minimum_total_ram_gb:
            ctx.logger.warn(
                "If you are using Bazel regularly, {}G RAM is suboptimal".
                format(input_data.total_ram))

        return ValidationResult(input_data, Status.OK)
Exemplo n.º 10
0
def validation_result_with(data, status: Status = Status.NOT_FOUND):
    return ValidationResult(data, status)
Exemplo n.º 11
0
    def validate(self, input_data, ctx: Context) -> ValidationResult:
        if input_data is None:
            ctx.logger.warn("{} not installed!".format(command))
            return ValidationResult(input_data, Status.NOT_FOUND)

        return ValidationResult(input_data, Status.OK)
Exemplo n.º 12
0
def validation_result_with(status: Status):
    return ValidationResult(None, status)
Exemplo n.º 13
0
def validation_result_with(status: Status):
    return ValidationResult(python_info_with(), status)
Exemplo n.º 14
0
def validation_not_found_result():
    return ValidationResult(None, Status.NOT_FOUND)
Exemplo n.º 15
0
def validation_result_with(status: Status, auth_ok=True, docker_ok=True):
    return ValidationResult(
        GCloudConfig(account="acc", auth_ok=auth_ok, docker_ok=docker_ok),
        status)
Exemplo n.º 16
0
def validation_result_with(status: Status):
    return ValidationResult(XcodeInfo(path="/"), status)