Example #1
0
def download_tarball(tarball_url):
    '''
    Downloads a tarball to /tmp and returns the path
    '''
    try:
        tarball_filename = tempfile.mkstemp(prefix='armada')[1]
        response = requests.get(tarball_url)
        with open(tarball_filename, 'wb') as f:
            f.write(response.content)
    except Exception:
        raise source_exceptions.TarballDownloadException(tarball_url)
    return tarball_filename
Example #2
0
def download_tarball(tarball_url, verify=False):
    '''
    Downloads a tarball to /tmp and returns the path
    '''
    try:
        if not verify:
            urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)

        tarball_filename = tempfile.mkstemp(prefix='armada')[1]
        response = requests.get(tarball_url, verify=verify)

        with open(tarball_filename, 'wb') as f:
            f.write(response.content)

        return tarball_filename
    except Exception:
        raise source_exceptions.TarballDownloadException(tarball_url)
Example #3
0
def download_tarball(tarball_url, verify=False, proxy_server=None):
    '''
    Downloads a tarball to /tmp and returns the path
    '''
    try:
        if not verify:
            urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
        kwargs = {}
        if proxy_server:
            kwargs['proxies'] = {
                'http': proxy_server,
                'https': proxy_server,
                'ftp': proxy_server
            }
        tarball_filename = tempfile.mkstemp(prefix='armada')[1]
        response = requests.get(tarball_url, verify=verify, **kwargs)

        with open(tarball_filename, 'wb') as f:
            f.write(response.content)

        return tarball_filename
    except Exception:
        raise source_exceptions.TarballDownloadException(tarball_url)