def _extract_submission(self, filename):
    """Extracts submission and moves it into self._extracted_submission_dir."""
    # verify filesize
    file_size = os.path.getsize(filename)
    if file_size > MAX_SUBMISSION_SIZE_ZIPPED:
      logging.error('Submission archive size %d is exceeding limit %d',
                    file_size, MAX_SUBMISSION_SIZE_ZIPPED)
      return False
    # determime archive type
    exctract_command_tmpl = get_extract_command_template(filename)
    if not exctract_command_tmpl:
      logging.error('Input file has to be zip, tar or tar.gz archive; however '
                    'found: %s', filename)
      return False
    # extract archive
    submission_dir = os.path.dirname(filename)
    submission_basename = os.path.basename(filename)
    logging.info('Extracting archive %s', filename)
    retval = shell_call(
        ['docker', 'run',
         '--network=none',
         '-v', '{0}:/input_dir'.format(submission_dir),
         '-v', '{0}:/output_dir'.format(self._tmp_extracted_dir),
         'busybox:1.27.2'] + exctract_command_tmpl,
        src=os.path.join('/input_dir', submission_basename),
        dst='/output_dir')
    if not retval:
      logging.error('Failed to extract submission from file %s', filename)
      return False
    if not make_directory_writable(self._tmp_extracted_dir):
      return False
    # find submission root
    root_dir = self._tmp_extracted_dir
    root_dir_content = [d for d in os.listdir(root_dir) if d != '__MACOSX']
    if (len(root_dir_content) == 1
        and os.path.isdir(os.path.join(root_dir, root_dir_content[0]))):
      logging.info('Looks like submission root is in subdirectory "%s" of '
                   'the archive', root_dir_content[0])
      root_dir = os.path.join(root_dir, root_dir_content[0])
    # Move files to self._extracted_submission_dir.
    # At this point self._extracted_submission_dir does not exist,
    # so following command will simply rename root_dir into
    # self._extracted_submission_dir
    if not shell_call(['mv', root_dir, self._extracted_submission_dir]):
      logging.error('Can''t move submission files from root directory')
      return False
    return True
Extracts submission and moves it into self._extracted_submission_dir.