Пример #1
0
def guess_input_file(uploaded_file, filename):
    """Guess the main test case file from an archive."""
    for file_pattern in RUN_FILE_PATTERNS:
        blob_reader = _read_to_bytesio(uploaded_file.gcs_path)
        file_path_input = archive.get_first_file_matching(
            file_pattern, blob_reader, filename)
        if file_path_input:
            return file_path_input

    return None
Пример #2
0
    def _get_executable_path(self, upload_info):
        """Get executable path."""
        executable_path = self.request.get('executable_path')
        if not upload_info:
            return executable_path

        if upload_info.size > ARCHIVE_READ_SIZE_LIMIT:
            return executable_path

        if not executable_path:
            executable_path = 'run'  # Check for default.

        reader = self._read_to_bytesio(upload_info.gcs_path)
        return archive.get_first_file_matching(executable_path, reader,
                                               upload_info.filename)
Пример #3
0
    def _get_launcher_script(self, upload_info):
        """Get launcher script path."""
        launcher_script = self.request.get('launcher_script')
        if not upload_info:
            return launcher_script

        if not launcher_script:
            return None

        if upload_info.size > ARCHIVE_READ_SIZE_LIMIT:
            return launcher_script

        reader = self._read_to_bytesio(upload_info.gcs_path)
        launcher_script = archive.get_first_file_matching(
            launcher_script, reader, upload_info.filename)
        if not launcher_script:
            raise helpers.EarlyExitException(
                'Specified launcher script was not found in archive!', 400)

        return launcher_script