Ejemplo n.º 1
0
def test__get_command__python():
    c = "python main.py" if platform.system() == WINDOWS else "python3 main.py"
    assert get_command("main.py") == c

    c = "python main.pyc" if platform.system(
    ) == WINDOWS else "python3 main.pyc"
    assert get_command("main.pyc") == c
Ejemplo n.º 2
0
def document_func(funcname, doc):
    com = find_command(funcname)[0]
    if com:
        result = data.query("UPDATE dynamic SET help=? WHERE version=? AND name=?", (doc, com["version"], funcname))
        command.get_command(funcname).set_help(doc)
        return result
    else:
        raise InvalidFuncNameError, funcname
Ejemplo n.º 3
0
def test__get_command__no_exist():
    import command

    non_existent = "hopefullynothingiscalledthis"
    command.LANGUAGES[frozenset({non_existent})] = (non_existent, )

    with pytest.raises(AssertionError):
        assert get_command(f"main.{non_existent}")
Ejemplo n.º 4
0
def test__judge_program__ac():
    c = get_command("tests/solutions/ac_tester.py")
    r = judge_program(c, [([""], [""]) for _ in range(tc)],
                      time_limit=tl,
                      memory_limit=ml)
    assert r.verdict == judge.ANSWER_CORRECT
    assert r.passed == r.total == tc
    assert r.maximum_memory <= MEBIBYTE * ml
    assert r.maximum_time <= 1000 * tl
Ejemplo n.º 5
0
def test__judge_program__tle():
    c = get_command("tests/solutions/tle_tester.py")
    r = judge_program(c, [([""], [""]) for _ in range(tc)],
                      time_limit=tl,
                      memory_limit=ml)
    assert r.verdict == judge.TIME_LIMIT_EXCEEDED
    assert r.passed == 0
    assert r.total == tc
    assert r.maximum_memory <= MEBIBYTE * ml
    assert r.maximum_time > 1000 * tl
Ejemplo n.º 6
0
def test__judge_program__rte():
    c = get_command("tests/solutions/rte_tester.py")
    r = judge_program(c, [([""], [""]) for _ in range(tc)],
                      time_limit=tl,
                      memory_limit=ml)
    assert r.verdict == judge.RUNTIME_ERROR
    assert r.passed == 0
    assert r.total == tc
    assert r.maximum_memory <= MEBIBYTE * ml
    assert r.maximum_time <= 1000 * tl
Ejemplo n.º 7
0
async def on_message(message):
    if message.author == client.user:
        return

    if is_okuyasu_command(message):
        split_content = clean_message(message).split()
        if len(split_content) < 2:
            return
        command_name = split_content[1]
        command = get_command(command_name)
        if message.guild is not None or not command.needs_guild:
            await command.execute(message)
    else:
        await handle_moderate_command(message)
Ejemplo n.º 8
0
def main():
    MyOS = get_my_os_info()
    CsvFileReader = read_csv(get_csv_file_path(CSV_PATH))

    for row_data in CsvFileReader:
        # if condition_checker(row_data, ignore_rules): # NotImplemented
        #    continue
        # Grep with condition like kind of Tools, like CUI tool only.

        content: str = get_main_content_from_csv(row_data, MyOS.os_name)
        # I should have make content class.

        if not content:
            continue
        elif is_url(content):
            if is_github_api(content):
                # link should have been class.(url checker is required)
                download_link = get_download_link_from_github(
                    content,
                    MyOS.get_os_negaposi_dict(),
                    get_negaposi_rule_dict(row_data),
                    MyOS.readable_exts,
                )
            else:
                download_link = content
            download(
                download_link,
                make_downloaded_path(get_file_name_from_url(download_link),
                                     DOWNLOAD_DIR),
            )
        else:
            install_option, name = option_checker(content)

            if install_option == "s":
                run_in_terminal(
                    get_script(name, SCRIPT_DIR, MyOS.readable_exts))
            else:
                run_in_terminal(get_command(content, MyOS.option_dict))
Ejemplo n.º 9
0
def tag_help(node,context):
    """[help command] - Returns the documentation for command."""
    return command.get_command(get_var(node.attribute,context)).help(context.interface.prefix)
Ejemplo n.º 10
0
def main():
    parser = argparse.ArgumentParser(description="Test your programs.")
    parser.add_argument(
        "exercise_name", action="store", nargs="?", type=str,
        help="the name of the exercise to test your program for.")
    parser.add_argument(
        "program_path", action="store", nargs="?", type=str,
        help="the path to the program to test.")
    parser.add_argument(
        "-l", "--list_exercises", action="store_true",
        help="display a list of all the exercises.", dest="list_exercises")
    parser.add_argument(
        "-s", "--see_description", action="store_true",
        help="display the description for the given exercise.", dest="see_description")
    parser.add_argument(
        "-e", "--exercises_location", action="store", default=DEFAULT_EXERCISES,
        help="set the base directory of the exercises.", dest="exercises_location")
    parser.add_argument(
        "-m", "--manual_command", action="store_true",
        help="enable this flag if you are entering the full command to run your program under "
             "`program_path` (instead of just the file name).", dest="manual_command")
    arguments = parser.parse_args()

    if arguments.list_exercises:
        lessons_list = exercise.list_exercises(arguments.exercises_location)
        lessons_list = [f"  тоб {lesson_name}" for lesson_name in lessons_list]

        display.display(f"Found {len(lessons_list)} lessons:")
        display.display("\n".join(lessons_list))
        sys.exit(0)

    if arguments.see_description:
        if arguments.exercise_name is None:
            raise AssertionError("no exercise name was specified")

        display.display(exercise.get_description(
            arguments.exercises_location, arguments.exercise_name
        ))
        sys.exit(0)

    if arguments.exercise_name is None or arguments.program_path is None:
        parser.print_help()

        missing_value = "exercise_name" if arguments.exercise_name is None else "program_path"
        raise AssertionError(f"the argument `{missing_value}` is missing")

    program_command = arguments.program_path
    if not arguments.manual_command:
        if not os.path.isfile(arguments.program_path):
            raise AssertionError(f"the file `{arguments.program_path}` does not exist")
        program_command = command.get_command(arguments.program_path)

    specifications = exercise.get_specs(arguments.exercises_location, arguments.exercise_name)

    display.d_exercise_specs(**specifications)
    result = judge.judge_program(
        program_command,
        **specifications,
        progress_hook=display.d_progress_hook
    )
    display.d_judging_summary(result)
Ejemplo n.º 11
0
            print(row_data)
            print(MyOS.os_name)

            continue
        elif is_url(content):
            if is_github_api(get_main_content_from_csv(content, MyOS)):
                download_link = get_download_link_from_github(
                    content,
                    MyOS,
                    get_negaposi_rule_dict(row_data),
                )
            else:
                download_link = content
            download(
                download_link,
                make_downloaded_path(get_file_name_from_url(download_link),
                                     DOWNLOAD_DIR),
            )
        else:
            install_option, name = option_checker(content)

            if install_option == "s":
                run_in_terminal(
                    get_script(name, SCRIPT_DIR, MyOS.readable_exts))
            else:
                run_in_terminal(get_command(content, MyOS.option_dict))


if __name__ == "__main__":
    main()
Ejemplo n.º 12
0
def test__get_command__default():
    assert get_command("main") == "./main"
    assert get_command("main.exe") == "./main.exe"