def getCatalogs(cataloglist):
    """Retrieves the catalogs from the server and populates our catalogs
    dictionary.
    """
    #global CATALOG
    catalogbaseurl = munkicommon.pref('CatalogURL') or \
                     munkicommon.pref('SoftwareRepoURL') + '/catalogs/'
    if not catalogbaseurl.endswith('?') and not catalogbaseurl.endswith('/'):
        catalogbaseurl = catalogbaseurl + '/'
    munkicommon.display_debug2('Catalog base URL is: %s', catalogbaseurl)
    catalog_dir = os.path.join(munkicommon.pref('ManagedInstallDir'),
                               'catalogs')

    for catalogname in cataloglist:
        if not catalogname in CATALOG:
            catalogurl = catalogbaseurl + urllib2.quote(
                catalogname.encode('UTF-8'))
            catalogpath = os.path.join(catalog_dir, catalogname)
            munkicommon.display_detail('Getting catalog %s...', catalogname)
            message = 'Retrieving catalog "%s"...' % catalogname
            try:
                dummy_value = getResourceIfChangedAtomically(
                    catalogurl, catalogpath, message=message)
            except fetch.MunkiDownloadError, err:
                munkicommon.display_error(
                    'Could not retrieve catalog %s from server: %s',
                    catalogname, err)
            else:
                try:
                    catalogdata = FoundationPlist.readPlist(catalogpath)
                except FoundationPlist.NSPropertyListSerializationException:
                    munkicommon.display_error(
                        'Retreived catalog %s is invalid.', catalogname)
                    try:
                        os.unlink(catalogpath)
                    except (OSError, __HOLE__):
                        pass
                else:
                    CATALOG[catalogname] = makeCatalogDB(catalogdata)
dataset/ETHPy150Open munki/munki/code/client/munkilib/updatecheck.py/getCatalogs