summaryrefslogtreecommitdiff
path: root/tools/generate-tempest-plugins-list.py
diff options
context:
space:
mode:
authorMasayuki Igawa <masayuki@igawa.io>2017-07-03 16:31:40 +0900
committerMasayuki Igawa <masayuki@igawa.io>2017-07-04 13:19:06 +0900
commit3e1f330236fdb0af692099f91ee3435d273a7bad (patch)
tree090781b2657b26cef462b83639f1e47f8230ce93 /tools/generate-tempest-plugins-list.py
parent479863dd47beeb35aef5fd5541956658940c48cc (diff)
downloadtempest-3e1f330236fdb0af692099f91ee3435d273a7bad.tar.gz
Fix import error "No module named six.moves" for plugin sanity job
This commit fixes the import error "No module named six.moves" without using the module for the plugin sanity job. Because the job call the script directly. Change-Id: Id0fa1b15fe443d65a1b6ca008e490d0fa54d6b32
Diffstat (limited to 'tools/generate-tempest-plugins-list.py')
-rw-r--r--tools/generate-tempest-plugins-list.py15
1 files changed, 11 insertions, 4 deletions
diff --git a/tools/generate-tempest-plugins-list.py b/tools/generate-tempest-plugins-list.py
index 5e63c0dd3..99df0d120 100644
--- a/tools/generate-tempest-plugins-list.py
+++ b/tools/generate-tempest-plugins-list.py
@@ -26,7 +26,14 @@
import json
import re
-from six.moves import urllib
+try:
+ # For Python 3.0 and later
+ from urllib.error import HTTPError as HTTPError
+ import urllib.request as urllib
+except ImportError:
+ # Fall back to Python 2's urllib2
+ import urllib2 as urllib
+ from urllib2 import HTTPError as HTTPError
url = 'https://review.openstack.org/projects/'
@@ -51,9 +58,9 @@ def is_in_openstack_namespace(proj):
def has_tempest_plugin(proj):
try:
- r = urllib.request.urlopen(
+ r = urllib.urlopen(
"https://git.openstack.org/cgit/%s/plain/setup.cfg" % proj)
- except urllib.error.HTTPError as err:
+ except HTTPError as err:
if err.code == 404:
return False
p = re.compile('^tempest\.test_plugins', re.M)
@@ -62,7 +69,7 @@ def has_tempest_plugin(proj):
else:
False
-r = urllib.request.urlopen(url)
+r = urllib.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.