From 4d36e2553afe350f5a824f25819abcea7cd86011 Mon Sep 17 00:00:00 2001 From: Al Date: Mon, 29 Aug 2016 00:32:29 -0400 Subject: [PATCH] [utils] Using curl with redirects and retries for download_file --- scripts/geodata/file_utils.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/scripts/geodata/file_utils.py b/scripts/geodata/file_utils.py index bbddd948..5e27fcb6 100644 --- a/scripts/geodata/file_utils.py +++ b/scripts/geodata/file_utils.py @@ -1,10 +1,13 @@ import os import subprocess +import six -def download_file(url, dest): +def download_file(url, dest, retries=3, retry_delay=5): ensure_dir(os.path.dirname(dest)) - return subprocess.call(['wget', url, '-O', dest, '--quiet']) == 0 + return subprocess.call(['curl', url, '-L', '--retry', six.text_type(retries), + '--retry-delay', six.text_type(retry_delay), + '-o', dest, '--silent']) == 0 def unzip_file(filename, dest):