swc-windows-installer.py: Use the stdlib's urlopen()
authorW. Trevor King <wking@tremily.us>
Wed, 20 Mar 2013 23:30:09 +0000 (19:30 -0400)
committerW. Trevor King <wking@tremily.us>
Mon, 21 Oct 2013 03:55:19 +0000 (20:55 -0700)
This way I can test the script (on Linux, but whatever) without having
to install an additional package.

setup/swc-windows-installer.py

index 58c1b29b78899609ca6f224e6ba20209645f6a43..c0bde19f800100e1ced14e98f706dbcb14c551a8 100755 (executable)
@@ -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']