aboutsummaryrefslogtreecommitdiffstats
path: root/ez_setup.py
diff options
context:
space:
mode:
Diffstat (limited to 'ez_setup.py')
-rw-r--r--ez_setup.py20
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']