Skip to content

Commit

Permalink
better fixes for urllib and urllib2 imports under Python3
Browse files Browse the repository at this point in the history
  • Loading branch information
glyphobet committed Jun 15, 2012
1 parent c71e9eb commit 2bb5007
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions virtualenv-burrito.py
Expand Up @@ -9,11 +9,14 @@
import sys
import os
import csv
import urllib
try:
import urllib2
from urllib import urlretrieve
except ImportError: # Python >= 3
import urllib.request as urllib2
from urllib.request import urlretrieve
try:
from urllib2 import urlopen
except ImportError: # Python >= 3
from urllib.request import urlopen
import shutil
import glob
import tempfile
Expand Down Expand Up @@ -60,7 +63,7 @@ def download(url, digest):
name = url.split('/')[-1]
print(" Downloading", name, "…")
try:
filename = urllib.urlretrieve(url)[0]
filename = urlretrieve(url)[0]
except Exception as e:
sys.stderr.write("\nERROR - Unable to download %s: %s %s\n"
% (url, type(e), str(e)))
Expand Down Expand Up @@ -178,7 +181,7 @@ def upgrade_package(filename, name, version):
def check_versions(selfcheck=True):
"""Return packages which can be upgraded."""
try:
fp = urllib2.urlopen(VERSIONS_URL)
fp = urlopen(VERSIONS_URL)
except Exception as e:
sys.stderr.write("\nERROR - Couldn't open versions file at %s: %s %s\n"
% (VERSIONS_URL, type(e), str(e)))
Expand Down

0 comments on commit 2bb5007

Please sign in to comment.