def GetComputerManifest(uuid=None, client_id=None, packagemap=False):
  """For a computer uuid or client_id, return the current manifest.

  Args:
    uuid: str, computer uuid    OR
    client_id: dict, client_id
    packagemap: bool, default False, whether to return packagemap or not
  Returns:
    if packagemap, dict = {
        'plist': plist.MunkiManifestPlist instance,
        'packagemap': {   # if packagemap == True
            'Firefox': 'Firefox-3.x.x.x.dmg',
        },
    }

    if not packagemap, str, manifest plist
  Raises:
    ValueError: error in type of arguments supplied to this method
    ComputerNotFoundError: computer cannot be found for uuid
    ManifestNotFoundError: manifest requested is invalid (not found)
    ManifestDisabledError: manifest requested is disabled
  """
  if client_id is None and uuid is None:
    raise ValueError('uuid or client_id must be supplied')

  if client_id is not None:
    if type(client_id) is not dict:
      raise ValueError('client_id must be dict')
    uuid = client_id.get('uuid')

  user_settings = None
  if uuid is not None:
    c = models.Computer.get_by_key_name(uuid)
    if not c:
      raise ComputerNotFoundError

    user_settings = c.user_settings
    client_id = {
        'uuid': uuid,
        'owner': c.owner,
        'hostname': c.hostname,
        'serial': c.serial,
        'config_track': c.config_track,
        'track': c.track,
        'site': c.site,
        'office': c.office,
        'os_version': c.os_version,
        'client_version': c.client_version,
        # TODO(user): Fix this; it may not be accurate.
        'on_corp': c.connections_on_corp > c.connections_off_corp,
        'last_notified_datetime': c.last_notified_datetime,
        'uptime': None,
        'root_disk_free': None,
        'user_disk_free': None,
    }

  # Step 1: Obtain a manifest for this uuid.
  manifest_plist_xml = None

  if IsPanicModeNoPackages():
    manifest_plist_xml = '%s%s' % (
        plist_module.PLIST_HEAD, plist_module.PLIST_FOOT)
  else:
    manifest_name = client_id['track']
    m = models.Manifest.MemcacheWrappedGet(manifest_name)
    if not m:
      raise ManifestNotFoundError(manifest_name)
    elif not m.enabled:
      raise ManifestDisabledError(manifest_name)

    manifest_plist_xml = GenerateDynamicManifest(
        m.plist, client_id, user_settings=user_settings)

  if not manifest_plist_xml:
    raise ManifestNotFoundError(manifest_name)

  # Step 1: Return now with xml if packagemap not requested.
  if not packagemap:
    return manifest_plist_xml

  # Step 2: Build lookup table from PackageName to PackageName-VersionNumber
  # for packages found in catalogs used by the client.

  manifest_plist = plist_module.MunkiManifestPlist(manifest_plist_xml)
  manifest_plist.Parse()

  packages = {}

  query = models.PackageInfo.all()
  for p in query:
    display_name = p.plist.get('display_name', None) or p.plist.get('name')
    display_name = display_name.strip()
    version = p.plist.get('version', '')
    packages[p.name] = '%s-%s' % (display_name, version)

  return {
      'plist': manifest_plist,
      'packagemap': packages,
  }
dataset/ETHPy150Open google/simian/src/simian/mac/munki/common.py/GetComputerManifest/original