diff options
author | Roman Lacko <backup.rlacko@gmail.com> | 2013-10-28 09:31:01 +0100 |
---|---|---|
committer | Roman Lacko <backup.rlacko@gmail.com> | 2013-10-28 09:31:01 +0100 |
commit | c7c59545cba2a35a7d5a129af8a919e043e54591 (patch) | |
tree | 306107b0db6ea1adb97aff120a4d6f778c69b6ec /ez_setup.py | |
parent | 2171f8cb9cba655b577b2cdf80767fe526ce518a (diff) |
Update ez_setup.py to latest version
Diffstat (limited to 'ez_setup.py')
-rw-r--r-- | ez_setup.py | 20 |
1 files changed, 16 insertions, 4 deletions
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'] |