diff options
-rw-r--r-- | ez_setup.py | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/ez_setup.py b/ez_setup.py index 03458b70..945f55d9 100644 --- a/ez_setup.py +++ b/ez_setup.py @@ -162,7 +162,12 @@ def download_file_powershell(url, target): '-Command', "(new-object System.Net.WebClient).DownloadFile(%(url)r, %(target)r)" % vars(), ] - subprocess.check_call(cmd) + try: + subprocess.check_call(cmd) + except subprocess.CalledProcessError: + if os.access(target, os.F_OK): + os.unlink(target) + raise def has_powershell(): if platform.system() != 'Windows': @@ -182,7 +187,12 @@ download_file_powershell.viable = has_powershell def download_file_curl(url, target): cmd = ['curl', url, '--silent', '--output', target] - subprocess.check_call(cmd) + try: + subprocess.check_call(cmd) + except subprocess.CalledProcessError: + if os.access(target, os.F_OK): + os.unlink(target) + raise def has_curl(): cmd = ['curl', '--version'] @@ -203,7 +213,8 @@ def download_file_wget(url, target): try: subprocess.check_call(cmd) except subprocess.CalledProcessError: - os.unlink(target) + if os.access(target, os.F_OK): + os.unlink(target) raise def has_wget(): |