(url, destdir, dry_run, logger=None)
return local_path
Download file from a given URL

    Args:
        url     : Download URL.
        destdir : Destination directory.
        dry_run : Dry-run mode.
        logger  : Optional logger to print messages.

    Returns:
        Path to downloaded file if the download is successful. None in
        dry-run mode or if the download fails.
Download file from a given URL
Download file from a given URL
def download_file(url, destdir, dry_run, logger=None):
    """Download file from a given URL

    Args:
        url     : Download URL.
        destdir : Destination directory.
        dry_run : Dry-run mode.
        logger  : Optional logger to print messages.

    Returns:
        Path to downloaded file if the download is successful. None in
        dry-run mode or if the download fails.

    """
    filename = url.split('/')[-1]
    local_path = os.path.join(destdir, filename)

    if (dry_run):
        print("Download: {}".format(url))
        print("Save at: {}".format(destdir))
        return

    if (logger is not None):
        logger.debug("Download {} and save at {}".format(url, destdir))

    try:
        urlretrieve(url, local_path, _print_urlretrieve_progress)
    except HTTPError as e:
        logger.error(str(e))
        return

    return local_path
def download_file ( url , destdir , dry_run , logger = None ) : filename = url . split ( '/' ) [ - 1 ] local_path = os . path . join ( destdir , filename ) if ( dry_run ) : print ( "Download: {}" . format ( url ) ) print ( "Save at: {}" . format ( destdir ) ) return if ( logger is not None ) : logger . debug ( "Download {} and save at {}" . format ( url , destdir ) ) try : urlretrieve ( url , local_path , _print_urlretrieve_progress ) except HTTPError as e : logger . error ( str ( e ) ) return return local_path