def download_file(filename, url):
    'Download a file from a given URL.\n\n  Args:\n    filename: the name of the file to download the URL to.\n    url: then URL to fetch.\n  '
    temp_filename = (filename + '.partial')
    find_in_path('curl')
    curl_cmd = ['curl', '--fail', '--location', '--stderr', '-', '-o', temp_filename]
    if (hasattr(sys.stdout, 'fileno') and os.isatty(sys.stdout.fileno())):
        curl_cmd.append('--progress-bar')
    else:
        curl_cmd += ['--silent', '--show-error']
    curl_cmd.append(url)
    if (log_level > LOG_WARN):
        log(('Downloading: %s [%s]' % (url, filename)))
    else:
        log(('Downloading: %s' % url.replace(GS_URL, '')))
    try:
        subprocess.check_call(curl_cmd)
    except subprocess.CalledProcessError as e:
        raise error.Error(('Error downloading file: %s' % str(e)))
    os.rename(temp_filename, filename)
Download a file from a given URL.

Args:
  filename: the name of the file to download the URL to.
  url: then URL to fetch.
def download_file(filename, url):
    'Download a file from a given URL.\n\n  Args:\n    filename: the name of the file to download the URL to.\n    url: then URL to fetch.\n  '
    temp_filename = (filename + '.partial')
    find_in_path('curl')
    curl_cmd = ['curl', '--fail', '--location', '--stderr', '-', '-o', temp_filename]
    if (hasattr(sys.stdout, 'fileno') and os.isatty(sys.stdout.fileno())):
        curl_cmd.append('--progress-bar')
    else:
        curl_cmd += ['--silent', '--show-error']
    curl_cmd.append(url)
    if (log_level > LOG_WARN):
        log(('Downloading: %s [%s]' % (url, filename)))
    else:
        log(('Downloading: %s' % url.replace(GS_URL, )))
    try:
        subprocess.check_call(curl_cmd)
    except subprocess.CalledProcessError as e:
        raise error.Error(('Error downloading file: %s' % str(e)))
    os.rename(temp_filename, filename)