original_docstring: Creates a tarfile with the configuration profile and client identity.
          Returns base64-encoded data representing the tarfile contents or
          None if something went wrong.
docstring: Creates a tarfile with the configuration profile and client identity.
  Returns base64-encoded data representing the tarfile contents or
  None if something went wrong.
docstring_tokens: Creates a tarfile with the configuration profile and client identity . Returns base64 - encoded data representing the tarfile contents or None if something went wrong .
code: def make_tar_file(given_serial,given_pki_contents,given_mobileconfig_contents):
      '''Creates a tarfile with the configuration profile and client identity.
          Returns base64-encoded data representing the tarfile contents or
          None if something went wrong.'''
      common.logging_info("Generating tar file response for %s." % given_serial)
  
      tar_file_name = "mes-%s.tar" % given_serial.upper()
      tar_file_path = os.path.join(config_app.TEMP_DIR,tar_file_name)
  
      # Remove existing archive:
      if os.path.exists(tar_file_path):
          os.remove(tar_file_path)
          common.logging_info("Removed existing temp file: %s." % tar_file_path)
  
      # Create file objects:
      member_files_array = []
      # Config profile:
      member_file_meta_dict = {}
      member_file_meta_dict['file_name'] = "client-enrollment.mobileconfig"
      member_file_meta_dict['file_size'] = len(given_mobileconfig_contents)
      member_file_meta_dict['file_object'] = StringIO(given_mobileconfig_contents)
      member_files_array.append(member_file_meta_dict)
  
      # Identity:
      member_file_meta_dict = {}
      member_file_meta_dict['file_name'] = "client-identity.pem"
      member_file_meta_dict['file_size'] = len(given_pki_contents)
      member_file_meta_dict['file_object'] = StringIO(given_pki_contents)
      member_files_array.append(member_file_meta_dict)
  
      # Create new archive:
      try:
          tar_file = tarfile.open(tar_file_path,'w')
      except tarfile.TarError:
          common.logging_error("Failed to create archive file at %s." % tar_file_path)
          return None
  
      # Add files to tar:
      for m in member_files_array:
          try:
              file_info = tarfile.TarInfo(m['file_name'])
              file_info.size = m['file_size']
              if file_info.size == 0:
                  common.logging_error("%s appears to be empty." % m['file_name'])
              tar_file.addfile(file_info,m['file_object'])
          except:
              common.logging_error("Failed to add %s to archive." % m['file_name'])
  
      tar_file.close()
  
      # Read archive:
      try:
          tar_file = open(tar_file_path,'r')
          attachment_contents = base64.b64encode(tar_file.read())
          tar_file.close()
      except tarfile.TarError:
          common.logging_error("Failed to read newly created archive at %s." % tar_file_path)
          return None
  
      # Remove archive:
      if os.path.exists(tar_file_path):
          os.remove(tar_file_path)
          common.logging_info("Removed archive: %s." % tar_file_path)
  
      # Return:
      return attachment_contents
code_tokens: def make_tar_file ( given_serial , given_pki_contents , given_mobileconfig_contents ) : common . logging_info ( "Generating tar file response for %s." % given_serial ) tar_file_name = "mes-%s.tar" % given_serial . upper ( ) tar_file_path = os . path . join ( config_app . TEMP_DIR , tar_file_name ) if os . path . exists ( tar_file_path ) : os . remove ( tar_file_path ) common . logging_info ( "Removed existing temp file: %s." % tar_file_path ) member_files_array = [ ] member_file_meta_dict = { } member_file_meta_dict [ 'file_name' ] = "client-enrollment.mobileconfig" member_file_meta_dict [ 'file_size' ] = len ( given_mobileconfig_contents ) member_file_meta_dict [ 'file_object' ] = StringIO ( given_mobileconfig_contents ) member_files_array . append ( member_file_meta_dict ) member_file_meta_dict = { } member_file_meta_dict [ 'file_name' ] = "client-identity.pem" member_file_meta_dict [ 'file_size' ] = len ( given_pki_contents ) member_file_meta_dict [ 'file_object' ] = StringIO ( given_pki_contents ) member_files_array . append ( member_file_meta_dict ) try : tar_file = tarfile . open ( tar_file_path , 'w' ) except tarfile . TarError : common . logging_error ( "Failed to create archive file at %s." % tar_file_path ) return None for m in member_files_array : try : file_info = tarfile . TarInfo ( m [ 'file_name' ] ) file_info . size = m [ 'file_size' ] if file_info . size == 0 : common . logging_error ( "%s appears to be empty." % m [ 'file_name' ] ) tar_file . addfile ( file_info , m [ 'file_object' ] ) except : common . logging_error ( "Failed to add %s to archive." % m [ 'file_name' ] ) tar_file . close ( ) try : tar_file = open ( tar_file_path , 'r' ) attachment_contents = base64 . b64encode ( tar_file . read ( ) ) tar_file . close ( ) except tarfile . TarError : common . logging_error ( "Failed to read newly created archive at %s." % tar_file_path ) return None if os . path . exists ( tar_file_path ) : os . remove ( tar_file_path ) common . logging_info ( "Removed archive: %s." % tar_file_path ) return attachment_contents
short_docstring: Creates a tarfile with the configuration profile and client identity.
short_docstring_tokens: Creates a tarfile with the configuration profile and client identity .
comment: '''Creates a tarfile with the configuration profile and client identity.
          Returns base64-encoded data representing the tarfile contents or
          None if something went wrong.'''$SEP$# Remove existing archive:$SEP$# Create file objects:$SEP$# Config profile:$SEP$# Identity:$SEP$# Create new archive:$SEP$# Add files to tar:$SEP$# Read archive:$SEP$# Remove archive:$SEP$# Return: