Example #1
0
def main():
    test_names = _get_test_names()

    for name in test_names:
        url_list = TESTS[name]()

        config = _downloader_config()
        download_dir = tempfile.mkdtemp(prefix=name + "-")
        request_list = [DownloadRequest(url, os.path.join(download_dir, _filename_from_url(url))) for url in url_list]
        listener = TestDownloadEventListener()

        print "%s: download %d files from %s to %s" % (
            name.upper(),
            len(url_list),
            url_list[0].rsplit("/", 1)[0],
            download_dir,
        )

        downloader = HTTPEventletRequestsDownloader(config, listener)
        start_time = datetime.datetime.now()
        downloader.download(request_list)
        finish_time = datetime.datetime.now()

        pprint(listener.callback_counts)
        print "Total download time: %s" % str(finish_time - start_time)
Example #2
0
current_dir = os.path.dirname(__file__)

ca_file = 'cdn.redhat.com-chain.crt'
#cert_file = '8538048783306757070.pem'
#key_file = '8538048783306757070-key.pem'
cert_file = '1359391926_4512.crt'
key_file = '1359391926_4512.key'

#repo_url = 'https://cdn.redhat.com/content/dist/rhel/server/6/6Server/x86_64/os/'
repo_url = 'https://cdn.redhat.com/content/dist/rhel/rhui/server/6/6.2/x86_64/os/'
#remote_file = 'repodata/repomd.xml'
remote_file = 'repodata/b18b7720dcbd7371aa388f2d0cfe10134a85871fc9eddea267778b2d255b1f10-updateinfo.xml.gz'

#dest_file = 'cdn-downloaded-repomd.xml'
dest_file = 'updateinfo.xml.gz'

requests = [DownloadRequest(repo_url + remote_file,
                            os.path.join(current_dir, dest_file))]

config = DownloaderConfig(
    ssl_validation=True,
    ssl_ca_cert_path=os.path.join(current_dir, ca_file),
    ssl_client_cert_path=os.path.join(current_dir, cert_file),
    ssl_client_key_path=os.path.join(current_dir, key_file),)

downloader = HTTPEventletRequestsDownloader(config)

downloader.download(requests)

Example #3
0
ca_file = 'cdn.redhat.com-chain.crt'
#cert_file = '8538048783306757070.pem'
#key_file = '8538048783306757070-key.pem'
cert_file = '1359391926_4512.crt'
key_file = '1359391926_4512.key'

#repo_url = 'https://cdn.redhat.com/content/dist/rhel/server/6/6Server/x86_64/os/'
repo_url = 'https://cdn.redhat.com/content/dist/rhel/rhui/server/6/6.2/x86_64/os/'
#remote_file = 'repodata/repomd.xml'
remote_file = 'repodata/b18b7720dcbd7371aa388f2d0cfe10134a85871fc9eddea267778b2d255b1f10-updateinfo.xml.gz'

#dest_file = 'cdn-downloaded-repomd.xml'
dest_file = 'updateinfo.xml.gz'

requests = [
    DownloadRequest(repo_url + remote_file,
                    os.path.join(current_dir, dest_file))
]

config = DownloaderConfig(
    ssl_validation=True,
    ssl_ca_cert_path=os.path.join(current_dir, ca_file),
    ssl_client_cert_path=os.path.join(current_dir, cert_file),
    ssl_client_key_path=os.path.join(current_dir, key_file),
)

downloader = HTTPEventletRequestsDownloader(config)

downloader.download(requests)