From: W. Trevor King Date: Wed, 20 Mar 2013 23:30:09 +0000 (-0400) Subject: swc-windows-installer.py: Use the stdlib's urlopen() X-Git-Tag: v0.1~34 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=52a6f2a20f7b63119946f60e2fe9ca0518a7b587;p=swc-setup-windows-installer.git swc-windows-installer.py: Use the stdlib's urlopen() This way I can test the script (on Linux, but whatever) without having to install an additional package. --- diff --git a/setup/swc-windows-installer.py b/setup/swc-windows-installer.py index 58c1b29..c0bde19 100755 --- a/setup/swc-windows-installer.py +++ b/setup/swc-windows-installer.py @@ -24,16 +24,18 @@ try: # Python 3 except ImportError: # Python 2 from StringIO import StringIO as _BytesIO import os.path +try: # Python 3 + from urllib.request import urlopen as _urlopen +except ImportError: # Python 2 + from urllib2 import urlopen as _urlopen import zipfile -import requests - def install_nano(install_directory): """Download and install the nano text editor""" url = "http://www.nano-editor.org/dist/v2.2/NT/nano-2.2.6.zip" - r = requests.get(url) - nano_zip_content = _BytesIO(r.content) + r = _urlopen(url) + nano_zip_content = _BytesIO(r.read()) nano_zip = zipfile.ZipFile(nano_zip_content) nano_files = ['nano.exe', 'cygwin1.dll', 'cygintl-8.dll', 'cygiconv-2.dll', 'cyggcc_s-1.dll']