Exemplo n.º 1
0
def print_compilation_status(printer: Printer, solution: str, max_sol_len: int,
                             loading_char: str,
                             status: SourceFileCompilationStatus):
    """
    Print the status of the compilation of a file
    """
    print_solution_column(printer, solution, max_sol_len)
    if status == SourceFileCompilationStatus.WAITING:
        printer.text("...")
    elif status == SourceFileCompilationStatus.COMPILING:
        printer.text(loading_char)
    elif status == SourceFileCompilationStatus.DONE:
        printer.green("OK", bold=True)
    else:
        printer.red("FAIL", bold=True)
    printer.text("\n")
Exemplo n.º 2
0
def print_subtask_result(printer: Printer, text: str,
                         result: SubtaskSolutionResult):
    """
    Print a string with a color based on the status of a subtask
    """
    if result == SubtaskSolutionResult.WAITING:
        printer.text(text)
    elif result == SubtaskSolutionResult.RUNNING:
        printer.text(text)
    elif result == SubtaskSolutionResult.ACCEPTED:
        printer.green(text)
    elif result == SubtaskSolutionResult.PARTIAL:
        printer.yellow(text)
    elif result == SubtaskSolutionResult.REJECTED:
        printer.red(text)
    else:
        raise ValueError(result)
Exemplo n.º 3
0
def print_testcase_generation_status(printer: Printer,
                                     status: TestcaseGenerationStatus):
    """
    Print the letter relative to the generation status
    """
    if status == TestcaseGenerationStatus.WAITING:
        printer.text(".")
    elif status == TestcaseGenerationStatus.GENERATING:
        printer.blue("g", bold=True)
    elif status == TestcaseGenerationStatus.GENERATED:
        printer.text("G")
    elif status == TestcaseGenerationStatus.VALIDATING:
        printer.blue("v", bold=True)
    elif status == TestcaseGenerationStatus.VALIDATED:
        printer.text("V")
    elif status == TestcaseGenerationStatus.SOLVING:
        printer.blue("s", bold=True)
    elif status == TestcaseGenerationStatus.DONE:
        printer.green("S", bold=True)
    else:
        printer.red("F", bold=True)
Exemplo n.º 4
0
def print_statement_result(printer: Printer, name: str, statement: Statement,
                           max_sol_len: int, loading: str):
    """
    Print the row of a statement file, including the dependencies
    """
    print_solution_column(printer, name, max_sol_len)
    if statement.compilation_status == StatementCompilationStatus.WAITING:
        printer.text("...")
    elif statement.compilation_status == \
            StatementCompilationStatus.COMPILING_DEPS:
        printer.blue("d")
    elif statement.compilation_status == \
            StatementCompilationStatus.COMPILED_DEPS:
        printer.text("D")
    elif statement.compilation_status == StatementCompilationStatus.COMPILING:
        printer.text(loading)
    elif statement.compilation_status == StatementCompilationStatus.DONE:
        printer.green("OK")
    elif statement.compilation_status == StatementCompilationStatus.FAILED:
        printer.red("FAIL")
    else:
        raise ValueError("Invalid compilation status " +
                         str(statement.compilation_status))
    printer.text(" ")
    if statement.other_executions:
        printer.text("[")
        for dep in statement.other_executions:
            if dep.status == StatementDepCompilationStatus.WAITING:
                printer.text(".")
            elif dep.status == StatementDepCompilationStatus.RUNNING:
                printer.text(loading)
            elif dep.status == StatementDepCompilationStatus.DONE:
                printer.green("✓")
            elif dep.status == StatementDepCompilationStatus.FAILED:
                printer.red("F")
            else:
                raise ValueError("Invalid dependency status " +
                                 str(dep.status))
        printer.text("]")
    printer.text("\n")
Exemplo n.º 5
0
def print_testcase_solution_result(printer: Printer, loading: str,
                                   info: TestcaseSolutionInfo):
    """
    Print the letter relative to the status of solution
    """
    if info.status == TestcaseSolutionStatus.WAITING:
        printer.text(".")
    elif info.status == TestcaseSolutionStatus.SOLVING:
        printer.blue(loading)
    elif info.status == TestcaseSolutionStatus.SOLVED:
        printer.text("s")
    elif info.status == TestcaseSolutionStatus.CHECKING:
        printer.text(loading)
    elif info.status == TestcaseSolutionStatus.SKIPPED:
        printer.text("X")
    elif info.checked and info.status == TestcaseSolutionStatus.ACCEPTED:
        printer.green("A", bold=True)
    elif info.checked and info.status == TestcaseSolutionStatus.WRONG_ANSWER:
        printer.red("W", bold=True)
    elif info.checked and info.status == TestcaseSolutionStatus.PARTIAL:
        printer.yellow("P", bold=True)
    elif info.checked and info.status == TestcaseSolutionStatus.FAILED:
        for res in info.result:
            if res.status != ResultStatus.SUCCESS:
                result = res
                break
        else:
            result = None
        # marked as failed even if no solution failed --> the checker
        if result is None:
            printer.bold("I", bold=True)
        elif result.status == ResultStatus.SIGNAL:
            printer.red("R", bold=True)
        elif result.status == ResultStatus.RETURN_CODE:
            printer.red("R", bold=True)
        elif result.status == ResultStatus.TIME_LIMIT:
            printer.red("T", bold=True)
        elif result.status == ResultStatus.WALL_LIMIT:
            printer.red("T", bold=True)
        elif result.status == ResultStatus.MEMORY_LIMIT:
            printer.red("M", bold=True)
        elif result.status == ResultStatus.MISSING_FILES:
            printer.red("F", bold=True)
        elif result.status == ResultStatus.INTERNAL_ERROR:
            printer.bold("I", bold=True)
        else:
            raise ValueError(result)
    elif not info.checked:
        printer.blue(loading)
    else:
        raise ValueError("{} {}".format(info.checked, info.status))