示例#1
0
    def _prepare(self):
        """Select a random solution and prepare it for submission.

        If task/ is the task directory, it might contain files (only
        if the submission format is with a single file) and
        directory. If it contains a file, it is assumed that it is the
        only element in the submission format, and is the basename
        without extension of the file. If it is a directory, all files
        inside are assumed to be part of the submission format with
        their basenames without extension.

        """
        GenericRequest._prepare(self)

        # Select a random directory or file inside the task directory.
        task_path = os.path.join(self.submissions_path, self.task[1])
        sources = os.listdir(task_path)
        source = random.choice(sources)
        self.source_path = os.path.join(task_path, source)

        # Compose the submission format
        self.files = []
        if os.path.isdir(self.source_path):
            submission_formats = os.listdir(self.source_path)
            self.files = [('%s.%%l' % (os.path.splitext(sf)[0]),
                           os.path.join(self.source_path, sf))
                          for sf in submission_formats]
        else:
            submission_format = os.path.splitext(source)[0]
            self.files = [('%s.%%l' % (submission_format), self.source_path)]
示例#2
0
 def _prepare(self):
     GenericRequest._prepare(self)
     # Let's generate an arbitrary input file.
     temp_file, temp_filename = tempfile.mkstemp()
     self.files = \
         list(zip(self.submission_format, self.filenames)) + \
         [("input", temp_filename)]
示例#3
0
 def _prepare(self):
     GenericRequest._prepare(self)
     # Let's generate an arbitrary input file.
     temp_file, temp_filename = tempfile.mkstemp()
     self.files = \
         list(zip(self.submission_format, self.filenames)) + \
         [("input", temp_filename)]
示例#4
0
文件: CWSRequests.py 项目: Nyrio/cms
    def _prepare(self):
        """Select a random solution and prepare it for submission.

        If task/ is the task directory, it might contain files (only
        if the submission format is with a single file) and
        directory. If it contains a file, it is assumed that it is the
        only element in the submission format, and is the basename
        without extension of the file. If it is a directory, all files
        inside are assumed to be part of the submission format with
        their basenames without extension.

        """
        GenericRequest._prepare(self)

        # Select a random directory or file inside the task directory.
        task_path = os.path.join(self.submissions_path, self.task[1])
        sources = os.listdir(task_path)
        source = random.choice(sources)
        lang = filename_to_language(source)
        if lang is not None:
            self.data["language"] = lang.name
        self.source_path = os.path.join(task_path, source)

        # Compose the submission format
        self.files = []
        if os.path.isdir(self.source_path):
            submission_formats = os.listdir(self.source_path)
            self.files = [('%s.%%l' % (os.path.splitext(sf)[0]),
                           os.path.join(self.source_path, sf))
                          for sf in submission_formats]
        else:
            submission_format = os.path.splitext(source)[0]
            self.files = [('%s.%%l' % (submission_format), self.source_path)]
示例#5
0
文件: CWSRequests.py 项目: Nyrio/cms
 def _prepare(self):
     GenericRequest._prepare(self)
     # Let's generate an arbitrary input file.
     # TODO: delete this file once we're done with it.
     _, temp_filename = tempfile.mkstemp()
     self.files = \
         list(zip(self.submission_format, self.filenames)) + \
         [("input", temp_filename)]
示例#6
0
 def _prepare(self):
     GenericRequest._prepare(self)
     # Let's generate an arbitrary input file.
     # TODO: delete this file once we're done with it.
     _, temp_filename = tempfile.mkstemp()
     self.files = \
         list(zip(self.submission_format, self.filenames)) + \
         [("input", temp_filename)]
示例#7
0
 def _prepare(self):
     GenericRequest._prepare(self)
     self.files = list(zip(self.submission_format, self.filenames))
示例#8
0
文件: CWSRequests.py 项目: Nyrio/cms
 def _prepare(self):
     GenericRequest._prepare(self)
     self.files = list(zip(self.submission_format, self.filenames))
示例#9
0
文件: CWSRequests.py 项目: Corea/cms
 def _prepare(self):
     GenericRequest._prepare(self)
     self.files = [(self.submission_format_element, self.filename)]
示例#10
0
 def _prepare(self):
     GenericRequest._prepare(self)
     self.files = [(self.submission_format_element, self.filename)]