aboutsummaryrefslogtreecommitdiffstats
path: root/ez_setup.py
diff options
context:
space:
mode:
authorJason R. Coombs <jaraco@jaraco.com>2013-08-19 09:59:04 -0400
committerJason R. Coombs <jaraco@jaraco.com>2013-08-19 09:59:04 -0400
commitc8d8126ffba6a9201b293fab0c8b0fc6346c129b (patch)
treef7b7796d9b7da742ccf882e66e389bfbbf8ef568 /ez_setup.py
parente282a1f42c47484c4fa52b8321c4ee367a150f2d (diff)
downloadexternal_python_setuptools-c8d8126ffba6a9201b293fab0c8b0fc6346c129b.tar.gz
external_python_setuptools-c8d8126ffba6a9201b293fab0c8b0fc6346c129b.tar.bz2
external_python_setuptools-c8d8126ffba6a9201b293fab0c8b0fc6346c129b.zip
Powershell isn't installed by default on Windows Server 2008. Also it's possible that Powershell is present on older systems. Now use direct detection of a Powershell executable to determine viability of that technique for a downloader. Fixes #67.
Diffstat (limited to 'ez_setup.py')
-rw-r--r--ez_setup.py17
1 files changed, 14 insertions, 3 deletions
diff --git a/ez_setup.py b/ez_setup.py
index 00cf47aa..837ef3f3 100644
--- a/ez_setup.py
+++ b/ez_setup.py
@@ -164,9 +164,20 @@ def download_file_powershell(url, target):
]
subprocess.check_call(cmd)
-download_file_powershell.viable = (
- lambda: platform.system() == 'Windows' and platform.win32_ver()[1] >= '6'
-)
+def has_powershell():
+ if platform.system() != 'Windows':
+ return False
+ cmd = ['powershell', '-Command', 'echo test']
+ devnull = open(os.path.devnull, 'wb')
+ try:
+ subprocess.check_call(cmd, stdout=devnull, stderr=devnull)
+ except:
+ return False
+ finally:
+ devnull.close()
+ return True
+
+download_file_powershell.viable = has_powershell
def download_file_curl(url, target):
cmd = ['curl', url, '--silent', '--output', target]