Ejemplo n.º 1
0
    def run(self, contest_id, task_id, user_id, language):
        # Source files are stored under cmstestsuite/code/.
        path = os.path.join(os.path.dirname(__file__), 'code')

        # List of files to submit
        files = []
        # For each file to be submitted

        # Set appropriate field name depending on format choice
        task_format = created_tasks[task_id]['submission_format_choice']
        if task_format == "simple":
            # Choose the correct file to submit.  There should only be one if
            # submission_format_choice is simple.
            filename = self.files[0]
            filename = filename.replace("%l", language)
            full_path = os.path.join(path, filename)

            # Create the correct field name
            field_name = '%s.%%l' % (created_tasks[task_id]['name'])

            # Set as file to be submitted
            files = [[field_name, full_path]]
        elif task_format == "other":
            # Create the list of field_name + filename pairs

            # First split the json-formatted list of strings in a regular
            # list of strings
            submission_format = json.loads(
                created_tasks[task_id]['submission_format'])
            filenames = map(lambda x: os.path.join(path, x), self.files)
            filenames = map(lambda x: x.replace("%l", language), filenames)
            files = zip(submission_format, filenames)
            files = map(list, files)

        # Submit our code.
        submission_id = cws_submit(contest_id, task_id, user_id, files,
                                   language)

        # Wait for evaluation to complete.
        result_info = get_evaluation_result(contest_id, submission_id)

        # Run checks.
        for check in self.checks:
            try:
                check.check(result_info)
            except TestFailure:
                # Our caller can deal with these.
                raise
Ejemplo n.º 2
0
    def run(self, contest_id, task_id, user_id, language):
        # Source files are stored under cmstestsuite/code/.
        path = os.path.join(os.path.dirname(__file__), 'code')

        # List of files to submit
        files = []
        # For each file to be submitted

        # Set appropriate field name depending on format choice
        task_format = created_tasks[task_id]['submission_format_choice']
        if task_format == "simple":
            # Choose the correct file to submit.  There should only be one if
            # submission_format_choice is simple.
            filename = self.files[0]
            filename = filename.replace("%l", language)
            full_path = os.path.join(path, filename)

            # Create the correct field name
            field_name = '%s.%%l'%(created_tasks[task_id]['name'])

            # Set as file to be submitted
            files = [[field_name, full_path]]
        elif task_format == "other":
            # Create the list of field_name + filename pairs

            # First split the json-formatted list of strings in a regular
            # list of strings
            submission_format = json.loads(created_tasks[task_id]['submission_format'])
            filenames = map(lambda x: os.path.join(path, x),self.files)
            filenames = map(lambda x: x.replace("%l", language), filenames)
            files = zip(submission_format,filenames)
            files = map(list,files)

        # Submit our code.
        submission_id = cws_submit(contest_id, task_id, user_id,
                                   files, language)

        # Wait for evaluation to complete.
        result_info = get_evaluation_result(contest_id, submission_id)

        # Run checks.
        for check in self.checks:
            try:
                check.check(result_info)
            except TestFailure:
                # Our caller can deal with these.
                raise
Ejemplo n.º 3
0
    def wait(self, contest_id, language):
        # This means we were not able to submit, hence the error
        # should have been already noted.
        if self.submission_id[language] is None:
            return

        # Wait for evaluation to complete.
        result_info = get_evaluation_result(
            contest_id, self.submission_id[language])

        # Run checks.
        for check in self.checks:
            try:
                check.check(result_info)
            except TestFailure:
                # Our caller can deal with these.
                raise
Ejemplo n.º 4
0
    def wait(self, contest_id, language):
        # This means we were not able to submit, hence the error
        # should have been already noted.
        if self.submission_id.get(language) is None:
            return

        # Wait for evaluation to complete.
        result_info = get_evaluation_result(contest_id,
                                            self.submission_id[language])

        # Run checks.
        for check in self.checks:
            try:
                check.check(result_info)
            except TestFailure:
                # Our caller can deal with these.
                raise
Ejemplo n.º 5
0
    def run(self, contest_id, task_id, user_id, language):
        # Source files are stored under cmstestsuite/code/.
        path = os.path.join(os.path.dirname(__file__), 'code')

        # Choose the correct file to submit.
        filename = self.filename.replace("%l", language)

        full_path = os.path.join(path, filename)

        # Submit our code.
        submission_id = cws_submit(contest_id, task_id, user_id,
                                   full_path, language)

        # Wait for evaluation to complete.
        result_info = get_evaluation_result(contest_id, submission_id)

        # Run checks.
        for check in self.checks:
            try:
                check.check(result_info)
            except TestFailure:
                # Our caller can deal with these.
                raise
Ejemplo n.º 6
0
 def wait(self, contest_id, unused_language):
     # Wait for evaluation to complete.
     for submission_id in self.submission_ids:
         get_evaluation_result(contest_id, submission_id)
Ejemplo n.º 7
0
 def wait(self, contest_id, unused_language):
     # Wait for evaluation to complete.
     for submission_id in self.submission_ids:
         get_evaluation_result(contest_id, submission_id)