def download_client_resources():
    # Munki's preferences can specify an explicit name
    # under ClientResourcesFilename
    # if that doesn't exist, use the primary manifest name as the
    # filename. If that fails, try site_default.zip
    filenames = []
    resources_name = munkicommon.pref('ClientResourcesFilename')
    if resources_name:
        if os.path.splitext(resources_name)[1] != '.zip':
            resources_name += '.zip'
        filenames.append(resources_name)
    else:
        filenames.append(munkicommon.report['ManifestName'] + '.zip')
    filenames.append('site_default.zip')

    resource_base_url = (
        munkicommon.pref('ClientResourceURL') or
        munkicommon.pref('SoftwareRepoURL') + '/client_resources/')
    resource_base_url = resource_base_url.rstrip('/') + '/'
    resource_dir = os.path.join(
        munkicommon.pref('ManagedInstallDir'), 'client_resources')
    munkicommon.display_debug2(
        'Client resources base URL is: %s', resource_base_url)
    # make sure local resource directory exists
    if not os.path.isdir(resource_dir):
        try:
            os.makedirs(resource_dir, 0755)
        except OSError, err:
            munkicommon.display_error(
                'Could not create %s' % resource_dir)
            return
    resource_archive_path = os.path.join(resource_dir, 'custom.zip')
    message = 'Getting client resources...'
    downloaded_resource_path = None
    for filename in filenames:
        resource_url = resource_base_url + filename
        try:
            dummy_value = getResourceIfChangedAtomically(
                resource_url, resource_archive_path, message=message)
            downloaded_resource_path = resource_archive_path
            break
        except fetch.MunkiDownloadError, err:
            munkicommon.display_debug1(
                'Could not retrieve client resources with name %s: %s',
                filename, err)
    if downloaded_resource_path is None:
        # make sure we don't have an old custom.zip hanging around
        if os.path.exists(resource_archive_path):
            try:
                os.unlink(resource_archive_path)
            except (OSError, IOError), err:
                munkicommon.display_error(
                    'Could not remove stale %s: %s', resource_archive_path, err)
break and continue statements are supported.
dataset/ETHPy150Open munki/munki/code/client/munkilib/updatecheck.py/download_client_resources--crossover with--dataset/ETHPy150Open timothycrosley/frosted/frosted/test/test_other.py/test_loopControl