diff options
author | Jenkins <jenkins@review.openstack.org> | 2017-06-29 01:20:04 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2017-06-29 01:20:04 +0000 |
commit | 1b786f1c6d4ed605be0f09647b44e97f8bd40664 (patch) | |
tree | 9ff9926bcd34727628bba03bba05e4f94b903ef5 /tools/generate-tempest-plugins-list.py | |
parent | f6288d705796ddeac971131ba91fcc9a0b2afb20 (diff) | |
parent | 73c33455bea758964402839257ac10f4b88445be (diff) | |
download | tempest-1b786f1c6d4ed605be0f09647b44e97f8bd40664.tar.gz |
Merge "Fix no attribute 'urlopen' error in python3"
Diffstat (limited to 'tools/generate-tempest-plugins-list.py')
-rw-r--r-- | tools/generate-tempest-plugins-list.py | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/tools/generate-tempest-plugins-list.py b/tools/generate-tempest-plugins-list.py index a33962be4..5e63c0dd3 100644 --- a/tools/generate-tempest-plugins-list.py +++ b/tools/generate-tempest-plugins-list.py @@ -26,12 +26,8 @@ import json import re -try: - # For Python 3.0 and later - import urllib -except ImportError: - # Fall back to Python 2's urllib2 - import urllib2 as urllib +from six.moves import urllib + url = 'https://review.openstack.org/projects/' @@ -55,18 +51,18 @@ def is_in_openstack_namespace(proj): def has_tempest_plugin(proj): try: - r = urllib.urlopen("https://git.openstack.org/cgit/%s/plain/setup.cfg" - % proj) - except urllib.HTTPError as err: + r = urllib.request.urlopen( + "https://git.openstack.org/cgit/%s/plain/setup.cfg" % proj) + except urllib.error.HTTPError as err: if err.code == 404: return False p = re.compile('^tempest\.test_plugins', re.M) - if p.findall(r.read()): + if p.findall(r.read().decode('utf-8')): return True else: False -r = urllib.urlopen(url) +r = urllib.request.urlopen(url) # Gerrit prepends 4 garbage octets to the JSON, in order to counter # cross-site scripting attacks. Therefore we must discard it so the # json library won't choke. |