def UploadMunkiPackage(
      self, filename, description, display_name, catalogs, manifests,
      install_types, unattended_install=False, unattended_uninstall=False,
      pkginfo_hooks=None, pkginfo_name=None):
    """Uploads a Munki PackageInfo plist along with a Package.

    Args:
      filename: str file name to upload.
      description: str description.
      display_name: str human readable display name.
      catalogs: list of str catalog names.
      manifests: list of str manifest names.
      install_types: list of str install types.
      unattended_install: bool, if True inject "unattended_install" bool into
              plist XML.
      unattended_uninstall: bool, if True inject "unattended_uninstall" bool
              into plist XML.
      pkginfo_hooks: optional, function to call with package info after
              generated
      pkginfo_name: optional, str name to override the pkginfo name.
    Returns:
      Tuple. (Str response body from upload, filename, name of the package,
              list of manifests, file size in kilobytes, SHA-256 hash of file)
    Raises:
      client.SimianClientError: if a client generated error occurs.
    """
    if not self._IsDiskImageReadOnly(filename):
      raise client.SimianClientError(
          '%s is not a read-only disk image' % filename)

    pkginfo = self._LoadPackageInfo(
        filename, description, display_name, catalogs)

    if unattended_install:
      pkginfo['unattended_install'] = True
      # TODO(user): remove backwards compatibility after a while...
      pkginfo['forced_install'] = True
    if unattended_uninstall:
      pkginfo['unattended_uninstall'] = True
      # TODO(user): remove backwards compatibility after a while...
      pkginfo['forced_uninstall'] = True
    if pkginfo_name:
      pkginfo['name'] = unicode(pkginfo_name)

    try:
      pkginfo.Validate()
    except plist.Error, e:
      raise client.SimianClientError((
          'Internal sanity check, plist error: %s' % str(e)))

    # TODO(user): Refactor so that this code block and cli.EditPackageInfo
    # share the same pkginfo_hooks iteration code.

    if pkginfo_hooks:
      changes = False
      for pkginfo_hook in pkginfo_hooks:
        output = pkginfo_hook(pkginfo)
        if output is True:
          logging.debug('pkginfo_hook resulted in no change')
        elif output is False:
          raise client.SimianClientError('Aborting upload by request.')
        else:
          pkginfo = output
          changes = True
          logging.debug('pkginfo_hook resulted in new pkginfo')

      # TODO(user): As part of the refactor suggestd above, these 1-off
      # copy steps to bring changes back from the plist into the option args
      # should be handled in a standard way.
      if changes:
        description = pkginfo['description']
        display_name = pkginfo['display_name']
        catalogs = pkginfo['catalogs']

    response, unused_filename, catalogs, manifests = self.UploadPackage(
        filename, description, display_name, catalogs, manifests,
        install_types, pkginfo.GetXml())

    name = pkginfo.GetPackageName()

    if 'installer_item_size' in pkginfo.GetContents():
      sha256_hash = pkginfo.GetContents()['installer_item_hash']
      size_kbytes = pkginfo.GetContents()['installer_item_size']
    else:
      sha256_hash = pkginfo.GetContents()['uninstaller_item_hash']
      size_kbytes = pkginfo.GetContents()['uninstaller_item_size']

    return (response, filename, name, catalogs, manifests, size_kbytes,
            sha256_hash)
dataset/ETHPy150Open google/simian/src/simian/mac/client/client.py/SimianClient.UploadMunkiPackage/original