From c7c59545cba2a35a7d5a129af8a919e043e54591 Mon Sep 17 00:00:00 2001 From: Roman Lacko Date: Mon, 28 Oct 2013 09:31:01 +0100 Subject: Update ez_setup.py to latest version --- ez_setup.py | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'ez_setup.py') diff --git a/ez_setup.py b/ez_setup.py index b02f3f17b..c3069e7a7 100644 --- a/ez_setup.py +++ b/ez_setup.py @@ -29,7 +29,7 @@ try: except ImportError: USER_SITE = None -DEFAULT_VERSION = "1.1.6" +DEFAULT_VERSION = "1.1.7" DEFAULT_URL = "https://pypi.python.org/packages/source/s/setuptools/" def _python_cmd(*args): @@ -151,6 +151,18 @@ def use_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL, return _do_download(version, download_base, to_dir, download_delay) +def _clean_check(cmd, target): + """ + Run the command to download target. If the command fails, clean up before + re-raising the error. + """ + try: + subprocess.check_call(cmd) + except subprocess.CalledProcessError: + if os.access(target, os.F_OK): + os.unlink(target) + raise + def download_file_powershell(url, target): """ Download the file at url to target using Powershell (which will validate @@ -162,7 +174,7 @@ def download_file_powershell(url, target): '-Command', "(new-object System.Net.WebClient).DownloadFile(%(url)r, %(target)r)" % vars(), ] - subprocess.check_call(cmd) + _clean_check(cmd, target) def has_powershell(): if platform.system() != 'Windows': @@ -182,7 +194,7 @@ download_file_powershell.viable = has_powershell def download_file_curl(url, target): cmd = ['curl', url, '--silent', '--output', target] - subprocess.check_call(cmd) + _clean_check(cmd, target) def has_curl(): cmd = ['curl', '--version'] @@ -200,7 +212,7 @@ download_file_curl.viable = has_curl def download_file_wget(url, target): cmd = ['wget', url, '--quiet', '--output-document', target] - subprocess.check_call(cmd) + _clean_check(cmd, target) def has_wget(): cmd = ['wget', '--version'] -- cgit v1.2.3