def getmanifest(partialurl, suppress_errors=False):
    """Gets a manifest from the server.

    Returns:
      string local path to the downloaded manifest.
    """
    #global MANIFESTS
    manifestbaseurl = (munkicommon.pref('ManifestURL') or
                       munkicommon.pref('SoftwareRepoURL') + '/manifests/')
    if (not manifestbaseurl.endswith('?') and
            not manifestbaseurl.endswith('/')):
        manifestbaseurl = manifestbaseurl + '/'
    manifest_dir = os.path.join(munkicommon.pref('ManagedInstallDir'),
                                'manifests')

    if (partialurl.startswith('http://') or
            partialurl.startswith('https://') or
            partialurl.startswith('file:/')):
        # then it's really a request for the client's primary manifest
        manifestdisplayname = os.path.basename(partialurl)
        manifesturl = partialurl
        partialurl = 'client_manifest'
        manifestname = 'client_manifest.plist'
    else:
        # request for nested manifest
        manifestdisplayname = partialurl
        manifestname = partialurl
        manifesturl = manifestbaseurl + urllib2.quote(partialurl)

    if manifestname in MANIFESTS:
        return MANIFESTS[manifestname]

    munkicommon.display_debug2('Manifest base URL is: %s', manifestbaseurl)
    munkicommon.display_detail('Getting manifest %s...', manifestdisplayname)
    manifestpath = os.path.join(manifest_dir, manifestname)

    # Create the folder the manifest shall be stored in
    destinationdir = os.path.dirname(manifestpath)
    try:
        os.makedirs(destinationdir)
    except __HOLE__ as e:
        # OSError will be raised if destinationdir exists, ignore this case
        if not os.path.isdir(destinationdir):
            if not suppress_errors:
                munkicommon.display_error(
                    'Could not create folder to store manifest %s: %s',
                    manifestdisplayname, e
                )

            return None

    message = 'Retrieving list of software for this machine...'
    try:
        dummy_value = getResourceIfChangedAtomically(
            manifesturl, manifestpath, message=message)
    except fetch.MunkiDownloadError, err:
        if not suppress_errors:
            munkicommon.display_error(
                'Could not retrieve manifest %s from the server: %s',
                manifestdisplayname, err)
        return None

    try:
        # read plist to see if it is valid
        dummy_data = FoundationPlist.readPlist(manifestpath)
    except FoundationPlist.NSPropertyListSerializationException:
        errormsg = 'manifest returned for %s is invalid.' % manifestdisplayname
        munkicommon.display_error(errormsg)
        try:
            os.unlink(manifestpath)
        except (OSError, IOError):
            pass
        raise ManifestException(errormsg)
    else:
        # plist is valid
        MANIFESTS[manifestname] = manifestpath
        return manifestpath
dataset/ETHPy150Open munki/munki/code/client/munkilib/updatecheck.py/getmanifest