Keep py3.X compatibility for urllib

Change-Id: Ib243de3c6dfef9fdc3e8d73629dc94cf45ee648b
Partial-Bug:#1280105
This commit is contained in:
Swapnil Kulkarni (coolsvap) 2015-12-24 11:57:12 +05:30
parent bec49a0e17
commit 533afe3671
3 changed files with 7 additions and 5 deletions

View File

@ -17,9 +17,10 @@ from __future__ import print_function
import contextlib
import json
import os
import six.moves.urllib.parse as urlparse
import six.moves.urllib.request as urlreq
import sys
import traceback
import urllib
import pkg_resources
@ -52,10 +53,10 @@ def release_data(req):
# Try to find it with various names...
attempted = []
for name in iter_names(req):
url = PYPI_LOCATION + "/%s/json" % (urllib.quote(name))
url = PYPI_LOCATION + "/%s/json" % (urlparse.quote(name))
if url in attempted:
continue
with contextlib.closing(urllib.urlopen(url)) as uh:
with contextlib.closing(urlreq.urlopen(url)) as uh:
if uh.getcode() != 200:
attempted.append(url)
continue

View File

@ -3,3 +3,4 @@
# process, which may cause wedges in the gate later.
fixtures>=1.3.1
Parsley
six>=1.9.0

View File

@ -35,8 +35,8 @@ checked.
import argparse
import datetime
import json
import six.moves.urllib.request as urlreq
import sys
import urllib2
import pkg_resources
@ -94,7 +94,7 @@ def get_releases_for_package(name, since):
our purposes.
"""
f = urllib2.urlopen("http://pypi.python.org/pypi/%s/json" % name)
f = urlreq.urlopen("http://pypi.python.org/pypi/%s/json" % name)
jsondata = f.read()
data = json.loads(jsondata)
releases = []