コード例 #1
0
ファイル: RunTests.py プロジェクト: invinciblejha/cms
def get_task_id(contest_id, user_id, task_module):
    # Create a task in the contest if we haven't already.
    if task_module not in task_id_map:
        # add the task itself.
        task_id = add_task(
            contest_id=contest_id,
            **task_module.task_info)

        # add the task's test data.
        data_path = os.path.join(
            os.path.dirname(task_module.__file__),
            "data")
        for input_file, output_file, public in task_module.test_cases:
            ipath = os.path.join(data_path, input_file)
            opath = os.path.join(data_path, output_file)
            add_testcase(task_id, ipath, opath, public)

        task_id_map[task_module] = task_id

        info("Creating task %s as id %d" % (
            task_module.task_info['name'], task_id))

        # We need to restart ScoringService to ensure it has picked up the
        # new task.
        restart_service("ScoringService", contest=contest_id)
    else:
        task_id = task_id_map[task_module]

    return task_id
コード例 #2
0
ファイル: testrunner.py プロジェクト: qnighy/cms
    def submit_tests(self):
        """Create the tasks, and submit for all languages in all tests.

        """
        # Pre-install all tasks in the contest. After this, we restart
        # ProxyService to ensure it reinitializes, picking up the new
        # tasks and sending them to RWS.
        for test in self.test_list:
            self.create_or_get_task(test.task_module)
        restart_service("ProxyService", contest=self.contest_id)

        for i, (test, lang) in enumerate(self._all_submissions()):
            logging.info("Submitting submission %s/%s: %s (%s)",
                         i + 1, self.n_submissions, test.name, lang)
            task_id = self.create_or_get_task(test.task_module)
            try:
                test.submit(self.contest_id, task_id, self.user_id, lang)
            except TestFailure as f:
                logging.error("(FAILED (while submitting): %s)", f.message)
                self.failures.append((test, lang, f.message))
コード例 #3
0
ファイル: testrunner.py プロジェクト: giomasce/cms
    def submit_tests(self):
        """Create the tasks, and submit for all languages in all tests.

        """
        # Pre-install all tasks in the contest. After this, we restart
        # ProxyService to ensure it reinitializes, picking up the new
        # tasks and sending them to RWS.
        for test in self.test_list:
            self.create_or_get_task(test.task_module)
        restart_service("ProxyService", contest=self.contest_id)

        for i, (test, lang) in enumerate(self._all_submissions()):
            logging.info("Submitting submission %s/%s: %s (%s)", i + 1,
                         self.n_submissions, test.name, lang)
            task_id = self.create_or_get_task(test.task_module)
            try:
                test.submit(self.contest_id, task_id, self.user_id, lang)
            except TestFailure as f:
                logging.error("(FAILED (while submitting): %s)", f.message)
                self.failures.append((test, lang, f.message))
コード例 #4
0
ファイル: RunTests.py プロジェクト: VittGam/cms
def get_task_id(contest_id, user_id, task_module):
    # Create a task in the contest if we haven't already.
    if task_module not in task_id_map:
        # add the task itself.
        task_id = add_task(
            contest_id=contest_id,
            token_initial="100",
            token_max="100",
            token_total="100",
            token_min_interval="0",
            token_gen_time="0",
            token_gen_number="0",
            max_submission_number="100",
            max_user_test_number="100",
            min_submission_interval=None,
            min_user_test_interval=None,
            **task_module.task_info)

        # add the task's test data.
        data_path = os.path.join(
            os.path.dirname(task_module.__file__),
            "data")
        for num, (input_file, output_file, public) \
                in enumerate(task_module.test_cases):
            ipath = os.path.join(data_path, input_file)
            opath = os.path.join(data_path, output_file)
            add_testcase(task_id, str(num), ipath, opath, public)

        task_id_map[task_module] = task_id

        info("Creating task %s as id %d" % (
            task_module.task_info['name'], task_id))

        # We need to restart ScoringService to ensure it has picked up the
        # new task.
        restart_service("ScoringService", contest=contest_id)
    else:
        task_id = task_id_map[task_module]

    return task_id
コード例 #5
0
def get_task_id(contest_id, user_id, task_module):
    # Create a task in the contest if we haven't already.
    if task_module not in task_id_map:
        # add the task itself.
        task_id = add_task(contest_id=contest_id,
                           token_initial="100",
                           token_max="100",
                           token_total="100",
                           token_min_interval="0",
                           token_gen_time="0",
                           token_gen_number="0",
                           max_submission_number="100",
                           max_usertest_number="100",
                           min_submission_interval="0",
                           min_usertest_interval="0",
                           **task_module.task_info)

        # add the task's test data.
        data_path = os.path.join(os.path.dirname(task_module.__file__), "data")
        for input_file, output_file, public in task_module.test_cases:
            ipath = os.path.join(data_path, input_file)
            opath = os.path.join(data_path, output_file)
            add_testcase(task_id, ipath, opath, public)

        task_id_map[task_module] = task_id

        info("Creating task %s as id %d" %
             (task_module.task_info['name'], task_id))

        # We need to restart ScoringService to ensure it has picked up the
        # new task.
        restart_service("ScoringService", contest=contest_id)
    else:
        task_id = task_id_map[task_module]

    return task_id
コード例 #6
0
def get_task_id(contest_id, user_id, task_module):
    name = task_module.task_info['name']

    # Have we done this before? Pull it out of our cache if so.
    if task_module in task_id_map:
        # Ensure we don't have multiple modules with the same task name.
        assert task_id_map[task_module][1] == task_module

        return task_id_map[name][0]

    task_create_args = {
        "token_mode": "finite",
        "token_max_number": "100",
        "token_min_interval": "0",
        "token_gen_initial": "100",
        "token_gen_number": "0",
        "token_gen_interval": "1",
        "token_gen_max": "100",
        "max_submission_number": "100",
        "max_user_test_number": "100",
        "min_submission_interval": None,
        "min_user_test_interval": None,
    }
    task_create_args.update(task_module.task_info)

    # Find if the task already exists in the contest.
    tasks = get_tasks(contest_id)
    if name in tasks:
        # Then just use the existing one.
        task = tasks[name]
        task_id = task['id']
        task_id_map[name] = (task_id, task_module)
        add_existing_task(contest_id, task_id, **task_create_args)
        return task_id

    # Otherwise, we need to add the task ourselves.
    task_id = add_task(contest_id, **task_create_args)

    # add any managers
    code_path = os.path.join(os.path.dirname(task_module.__file__), "code")
    if hasattr(task_module, 'managers'):
        for manager in task_module.managers:
            mpath = os.path.join(code_path, manager)
            add_manager(task_id, mpath)

    # add the task's test data.
    data_path = os.path.join(os.path.dirname(task_module.__file__), "data")
    for num, (input_file, output_file, public) \
            in enumerate(task_module.test_cases):
        ipath = os.path.join(data_path, input_file)
        opath = os.path.join(data_path, output_file)
        add_testcase(task_id, num, ipath, opath, public)

    task_id_map[name] = (task_id, task_module)

    info("Created task %s as id %d" % (name, task_id))

    # We need to restart ProxyService to ensure it reinitializes,
    # picking up the new task and sending it to RWS.
    restart_service("ProxyService", contest=contest_id)

    return task_id
コード例 #7
0
ファイル: RunFunctionalTests.py プロジェクト: MegaAlex/cms
def get_task_id(contest_id, user_id, task_module):
    name = task_module.task_info['name']

    # Have we done this before? Pull it out of our cache if so.
    if task_module in task_id_map:
        # Ensure we don't have multiple modules with the same task name.
        assert task_id_map[task_module][1] == task_module

        return task_id_map[name][0]

    task_create_args = {
        "token_mode": "finite",
        "token_max_number": "100",
        "token_min_interval": "0",
        "token_gen_initial": "100",
        "token_gen_number": "0",
        "token_gen_interval": "1",
        "token_gen_max": "100",
        "max_submission_number": "100",
        "max_user_test_number": "100",
        "min_submission_interval": None,
        "min_user_test_interval": None,
    }
    task_create_args.update(task_module.task_info)

    # Find if the task already exists in the contest.
    tasks = get_tasks(contest_id)
    if name in tasks:
        # Then just use the existing one.
        task = tasks[name]
        task_id = task['id']
        task_id_map[name] = (task_id, task_module)
        add_existing_task(contest_id, task_id, **task_create_args)
        return task_id

    # Otherwise, we need to add the task ourselves.
    task_id = add_task(contest_id, **task_create_args)

    # add any managers
    code_path = os.path.join(
        os.path.dirname(task_module.__file__),
        "code")
    if hasattr(task_module, 'managers'):
        for manager in task_module.managers:
            mpath = os.path.join(code_path, manager)
            add_manager(task_id, mpath)

    # add the task's test data.
    data_path = os.path.join(
        os.path.dirname(task_module.__file__),
        "data")
    for num, (input_file, output_file, public) \
            in enumerate(task_module.test_cases):
        ipath = os.path.join(data_path, input_file)
        opath = os.path.join(data_path, output_file)
        add_testcase(task_id, num, ipath, opath, public)

    task_id_map[name] = (task_id, task_module)

    info("Created task %s as id %d" % (name, task_id))

    # We need to restart ProxyService to ensure it reinitializes,
    # picking up the new task and sending it to RWS.
    restart_service("ProxyService", contest=contest_id)

    return task_id