Browse Source

Keep py3.X compatibility for urllib

Use six.moves.urllib.parse instead of urllib
Closes-Bug: #1280105

Change-Id: I861c32fe7333c3d30b5ae395c97df16f6b39f778
tags/9.0
LiuNanke 4 years ago
parent
commit
f707fa6189
2 changed files with 5 additions and 5 deletions
  1. +3
    -3
      nailgun/nailgun/middleware/static.py
  2. +2
    -2
      nailgun/nailgun/test/unit/test_openstack_config_handler.py

+ 3
- 3
nailgun/nailgun/middleware/static.py View File

@@ -15,7 +15,7 @@
# under the License.

import os.path
import urllib
import six.moves.urllib.parse as urlparse

from web.httpserver import StaticApp

@@ -29,7 +29,7 @@ class NailgunStaticApp(StaticApp):
path = path.split('?', 1)[0].split('#', 1)[0]
if path.startswith("/static/"):
path = path[7:]
path = os.path.normpath(urllib.unquote(path))
path = os.path.normpath(urlparse.unquote(path))
words = path.split('/')
words = filter(None, words)

@@ -60,7 +60,7 @@ class StaticMiddleware(object):
return self.app(environ, start_response)

def normpath(self, path):
path2 = os.path.normpath(urllib.unquote(path))
path2 = os.path.normpath(urlparse.unquote(path))
if path.endswith("/"):
path2 += "/"
return path2

+ 2
- 2
nailgun/nailgun/test/unit/test_openstack_config_handler.py View File

@@ -13,7 +13,7 @@
# under the License.

import mock
import urllib
import six.moves.urllib.parse as urlparse

from oslo_serialization import jsonutils

@@ -346,4 +346,4 @@ class TestOpenstackConfigHandlers(BaseIntegrationTest):
def _make_filter_url(cls, **kwargs):
return '{0}?{1}'.format(
reverse('OpenstackConfigCollectionHandler'),
urllib.urlencode(kwargs))
urlparse.urlencode(kwargs))

Loading…
Cancel
Save