def export_graders(self):
     HAS_GRADER = get_bool_environ('HAS_GRADER')
     if not HAS_GRADER:
         vp.print("No graders to export.")
         return
     vp.print("Exporting graders...")
     GRADER_DIR = os.environ.get('GRADER_DIR')
     check_dir_exists(GRADER_DIR, "graders directory")
     self.create_directory(self.GRADER_DIR_NAME)
     HAS_LANG_CPP = get_bool_environ('HAS_LANG_CPP')
     HAS_LANG_JAVA = get_bool_environ('HAS_LANG_JAVA')
     HAS_LANG_PASCAL = get_bool_environ('HAS_LANG_PASCAL')
     HAS_LANG_PYTHON = get_bool_environ('HAS_LANG_PYTHON')
     GRADER_NAME = os.environ.get('GRADER_NAME')
     grader_files = []
     if HAS_LANG_CPP:
         grader_files += [
             "cpp/{}.cpp".format(GRADER_NAME),
             "cpp/{}.h".format(PROBLEM_NAME),
         ]
     if HAS_LANG_JAVA:
         grader_files += [
             "java/{}.java".format(GRADER_NAME),
         ]
     if HAS_LANG_PYTHON:
         grader_files += [
             "py/{}.py".format(GRADER_NAME),
         ]
     if HAS_LANG_PASCAL:
         grader_files += [
             "pas/{}.pas".format(GRADER_NAME),
             "pas/{}lib.pas".format(GRADER_NAME),
         ]
     for grader_file in grader_files:
         grader_file_path = os.path.join(GRADER_DIR, grader_file)
         if os.path.isfile(grader_file_path):
             self.copy_file(
                 grader_file_path,
                 os.path.join(self.GRADER_DIR_NAME,
                              os.path.basename(grader_file)))
         else:
             vp.print(
                 "Grader file '{}' does not exist.".format(grader_file))
 def export_checker(self):
     HAS_CHECKER = get_bool_environ('HAS_CHECKER')
     if not HAS_CHECKER:
         vp.print("No checker to export.")
         return
     vp.print("Exporting checker...")
     CHECKER_DIR = os.environ.get('CHECKER_DIR')
     check_dir_exists(CHECKER_DIR, "Checker directory")
     checker_files = []
     for p in ["*.cpp", "*.h", "Makefile"]:
         checker_files += glob.glob(os.path.join(CHECKER_DIR, p))
     self.create_directory(self.CHECKER_DIR_NAME)
     for f in checker_files:
         self.copy_file(
             f, os.path.join(self.CHECKER_DIR_NAME, os.path.basename(f)))
 def export_manager(self):
     HAS_MANAGER = get_bool_environ('HAS_MANAGER')
     if not HAS_MANAGER:
         vp.print("No manager to export.")
         return
     vp.print("Exporting manager...")
     MANAGER_DIR = os.environ.get('MANAGER_DIR')
     check_dir_exists(MANAGER_DIR, "Manager directory")
     manager_files = []
     for p in ["*.cpp", "*.h", "Makefile"]:
         manager_files += glob.glob(os.path.join(MANAGER_DIR, p))
     self.create_directory(self.MANAGER_DIR_NAME)
     for f in manager_files:
         self.copy_file(
             f, os.path.join(self.MANAGER_DIR_NAME, os.path.basename(f)))
Beispiel #4
0
    def export_problem_global_data(self):
        json_file = "problem.json"
        vp.print("Writing '{}'...".format(json_file))
        PROBLEM_JSON = os.environ.get('PROBLEM_JSON')
        task_data = load_json(PROBLEM_JSON)

        task_type = task_data["type"]
        vp.print_var("task_type", task_type)

        task_type_params = task_data.get("type_params", {})

        if task_type == "Communication":
            num_processes = task_data.get("num_processes")
            if num_processes is not None:
                task_type_params[
                    "task_type_parameters_Communication_num_processes"] = num_processes

        if task_type == "Batch":
            HAS_GRADER = get_bool_environ("HAS_GRADER")
            if HAS_GRADER:
                compilation_type = "grader"
            else:
                compilation_type = "alone"
            task_type_params[
                "task_type_parameters_Batch_compilation"] = compilation_type

        problem_data_dict = {
            "code": task_data["name"],
            "name": task_data["title"],
            "time_limit": task_data["time_limit"],
            "memory_limit": task_data["memory_limit"] * 1024 * 1024,
            "score_precision": task_data.get("score_precision", 2),
            "task_type": task_type,
            "task_type_params": json.dumps(task_type_params),
        }

        problem_data_str = json.dumps(problem_data_dict)
        vp.print_var(json_file, problem_data_str)
        self.write_to_file(json_file, problem_data_str)
Beispiel #5
0
import sys
import os
import subprocess

from util import get_bool_environ, simple_usage_message, wait_process_success
from color_util import cprinterr, colors
import tests_util as tu

INTERNALS_DIR = os.environ.get('INTERNALS')
SPECIFIC_TESTS = get_bool_environ('SPECIFIC_TESTS')
SPECIFIED_TESTS_PATTERN = os.environ.get('SPECIFIED_TESTS_PATTERN')

if __name__ == '__main__':
    if len(sys.argv) != 2:
        simple_usage_message("<tests-dir>")
    tests_dir = sys.argv[1]

    try:
        test_name_list = tu.get_test_names_from_tests_dir(tests_dir)
    except tu.MalformedTestsException as e:
        cprinterr(colors.ERROR, "Error:")
        sys.stderr.write("{}\n".format(e))
        sys.exit(4)

    if SPECIFIC_TESTS:
        tu.check_pattern_exists_in_test_names(SPECIFIED_TESTS_PATTERN,
                                              test_name_list)
        test_name_list = tu.filter_test_names_by_pattern(
            test_name_list, SPECIFIED_TESTS_PATTERN)

    available_tests, missing_tests = tu.divide_tests_by_availability(
Beispiel #6
0
import sys
import os
import subprocess

from util import get_bool_environ, load_json, simple_usage_message, wait_process_success
from color_util import cprint, cprinterr, colors
from invoke_util import get_short_verdict, is_verdict_expected
import tests_util as tu


INTERNALS_DIR = os.environ.get('INTERNALS')
LOGS_DIR = os.environ.get('LOGS_DIR')
SUBTASKS_JSON = os.environ.get('SUBTASKS_JSON')
SOLUTIONS_JSON = os.environ.get('SOLUTIONS_JSON')
SPECIFIC_TESTS = get_bool_environ('SPECIFIC_TESTS')
SPECIFIED_TESTS_PATTERN = os.environ.get('SPECIFIED_TESTS_PATTERN')
SKIP_CHECK = get_bool_environ('SKIP_CHECK')


if __name__ == '__main__':
    if len(sys.argv) != 3:
        simple_usage_message("<tests-dir> <solution-path>")
    tests_dir = sys.argv[1]
    solution_filename = os.path.basename(sys.argv[2])

    solutions_data = dict(load_json(SOLUTIONS_JSON))
    solution_data = solutions_data.get(solution_filename, None)

    try:
        test_name_list = tu.get_test_names_from_tests_dir(tests_dir)
    except tu.MalformedTestsException as e:
import sys
import os
import json
import re
import subprocess

from util import get_bool_environ
from gen_data_parser import DataVisitor, parse_data_or_throw, DataParseError
from color_util import cprint, colors

BASE_DIR = os.environ.get('BASE_DIR')

WEB_TERMINAL = get_bool_environ('WEB_TERMINAL')

PROBLEM_NAME = os.environ.get('PROBLEM_NAME')
HAS_GRADER = get_bool_environ('HAS_GRADER')
HAS_MANAGER = get_bool_environ('HAS_MANAGER')
HAS_CHECKER = get_bool_environ('HAS_CHECKER')
if HAS_GRADER:
    GRADER_NAME = os.environ.get('GRADER_NAME')

HAS_LANG_CPP = get_bool_environ('HAS_LANG_CPP')
HAS_LANG_JAVA = get_bool_environ('HAS_LANG_JAVA')
HAS_LANG_PASCAL = get_bool_environ('HAS_LANG_PASCAL')
HAS_LANG_PYTHON = get_bool_environ('HAS_LANG_PYTHON')

PROBLEM_JSON = os.environ.get('PROBLEM_JSON')
SOLUTIONS_JSON = os.environ.get('SOLUTIONS_JSON')
SUBTASKS_JSON = os.environ.get('SUBTASKS_JSON')
GEN_DATA = os.environ.get('GEN_DATA')
GEN_DIR = os.environ.get('GEN_DIR')