From c8d8126ffba6a9201b293fab0c8b0fc6346c129b Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Mon, 19 Aug 2013 09:59:04 -0400 Subject: 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. --- ez_setup.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'ez_setup.py') 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] -- cgit v1.2.3