Fix urllib import issue for Python2/3 compatible code.

change urlparse to 'from six.moves.urllib.parse import urlparse'
and remove obsolete code

Story:2003430
Task:27479

Change-Id: I38e75f5faa55046517f1e479b18ebcef0304e471
Signed-off-by: Sun Austin <austin.sun@intel.com>
This commit is contained in:
Sun Austin 2018-10-15 17:08:34 +08:00
parent 1477d25d55
commit de91fb2ac1
2 changed files with 5 additions and 10 deletions

View File

@ -24,8 +24,9 @@ SQLAlchemy models for sm_api data.
""" """
import json import json
import urlparse
from six.moves.urllib.parse import urlparse
from oslo_config import cfg from oslo_config import cfg
from sqlalchemy import Column, ForeignKey, Integer, Boolean from sqlalchemy import Column, ForeignKey, Integer, Boolean
@ -46,7 +47,7 @@ cfg.CONF.register_opts(sql_opts, 'database')
def table_args(): def table_args():
engine_name = urlparse.urlparse(cfg.CONF.database_connection).scheme engine_name = urlparse(cfg.CONF.database_connection).scheme
if engine_name == 'mysql': if engine_name == 'mysql':
return {'mysql_engine': cfg.CONF.mysql_engine, return {'mysql_engine': cfg.CONF.mysql_engine,
'mysql_charset': "utf8"} 'mysql_charset': "utf8"}

View File

@ -23,7 +23,7 @@ import logging
import os import os
import socket import socket
import StringIO import StringIO
import urlparse from six.moves.urllib.parse import urlparse
try: try:
import ssl import ssl
@ -36,12 +36,6 @@ try:
except ImportError: except ImportError:
import simplejson as json import simplejson as json
# Python 2.5 compat fix
if not hasattr(urlparse, 'parse_qsl'):
import cgi
urlparse.parse_qsl = cgi.parse_qsl
from sm_client import exc from sm_client import exc
@ -59,7 +53,7 @@ class HTTPClient(object):
@staticmethod @staticmethod
def get_connection_params(endpoint, **kwargs): def get_connection_params(endpoint, **kwargs):
parts = urlparse.urlparse(endpoint) parts = urlparse(endpoint)
_args = (parts.hostname, parts.port, parts.path) _args = (parts.hostname, parts.port, parts.path)
_kwargs = {'timeout': (float(kwargs.get('timeout')) _kwargs = {'timeout': (float(kwargs.get('timeout'))