Remove six lib
Change-Id: I7f278088722a3e0e0fd502be45337c485d9f282b
This commit is contained in:
parent
991e46c1c9
commit
290b6ed2bd
@ -24,7 +24,6 @@ Exception definitions.
|
|||||||
import inspect
|
import inspect
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
import six
|
|
||||||
|
|
||||||
from cyborgclient.i18n import _
|
from cyborgclient.i18n import _
|
||||||
|
|
||||||
@ -444,7 +443,7 @@ def from_response(response, method, url):
|
|||||||
kwargs["message"] = (error.get("message") or
|
kwargs["message"] = (error.get("message") or
|
||||||
error.get("faultstring"))
|
error.get("faultstring"))
|
||||||
kwargs["details"] = (error.get("details") or
|
kwargs["details"] = (error.get("details") or
|
||||||
six.text_type(body))
|
str(body))
|
||||||
elif content_type.startswith("text/"):
|
elif content_type.startswith("text/"):
|
||||||
kwargs["details"] = getattr(response, 'text', '')
|
kwargs["details"] = getattr(response, 'text', '')
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ Base utilities to build API operation managers and objects on top of.
|
|||||||
|
|
||||||
import copy
|
import copy
|
||||||
|
|
||||||
import six.moves.urllib.parse as urlparse
|
import urllib.parse as urlparse
|
||||||
|
|
||||||
from cyborgclient.common.apiclient import base
|
from cyborgclient.common.apiclient import base
|
||||||
|
|
||||||
|
@ -26,8 +26,7 @@ import decorator
|
|||||||
from oslo_utils import encodeutils
|
from oslo_utils import encodeutils
|
||||||
from oslo_utils import strutils
|
from oslo_utils import strutils
|
||||||
import prettytable
|
import prettytable
|
||||||
import six
|
|
||||||
from six import moves
|
|
||||||
|
|
||||||
from cyborgclient.common.apiclient import exceptions
|
from cyborgclient.common.apiclient import exceptions
|
||||||
from cyborgclient.i18n import _
|
from cyborgclient.i18n import _
|
||||||
@ -299,10 +298,7 @@ def print_list(objs, fields, formatters=None, sortby_index=0,
|
|||||||
row.append(data)
|
row.append(data)
|
||||||
pt.add_row(row)
|
pt.add_row(row)
|
||||||
|
|
||||||
if six.PY3:
|
|
||||||
print(encodeutils.safe_encode(pt.get_string(**kwargs)).decode())
|
print(encodeutils.safe_encode(pt.get_string(**kwargs)).decode())
|
||||||
else:
|
|
||||||
print(encodeutils.safe_encode(pt.get_string(**kwargs)))
|
|
||||||
|
|
||||||
|
|
||||||
def keys_and_vals_to_strs(dictionary):
|
def keys_and_vals_to_strs(dictionary):
|
||||||
@ -313,7 +309,7 @@ def keys_and_vals_to_strs(dictionary):
|
|||||||
def to_str(k_or_v):
|
def to_str(k_or_v):
|
||||||
if isinstance(k_or_v, dict):
|
if isinstance(k_or_v, dict):
|
||||||
return keys_and_vals_to_strs(k_or_v)
|
return keys_and_vals_to_strs(k_or_v)
|
||||||
elif isinstance(k_or_v, six.text_type):
|
elif isinstance(k_or_v, str):
|
||||||
return str(k_or_v)
|
return str(k_or_v)
|
||||||
else:
|
else:
|
||||||
return k_or_v
|
return k_or_v
|
||||||
@ -332,12 +328,12 @@ def print_dict(dct, dict_property="Property", wrap=0):
|
|||||||
for k, v in dct.items():
|
for k, v in dct.items():
|
||||||
# convert dict to str to check length
|
# convert dict to str to check length
|
||||||
if isinstance(v, dict):
|
if isinstance(v, dict):
|
||||||
v = six.text_type(keys_and_vals_to_strs(v))
|
v = str(keys_and_vals_to_strs(v))
|
||||||
if wrap > 0:
|
if wrap > 0:
|
||||||
v = textwrap.fill(six.text_type(v), wrap)
|
v = textwrap.fill(str(v), wrap)
|
||||||
# if value has a newline, add in multiple rows
|
# if value has a newline, add in multiple rows
|
||||||
# e.g. fault with stacktrace
|
# e.g. fault with stacktrace
|
||||||
if v and isinstance(v, six.string_types) and r'\n' in v:
|
if v and isinstance(v, str) and r'\n' in v:
|
||||||
lines = v.strip().split(r'\n')
|
lines = v.strip().split(r'\n')
|
||||||
col1 = k
|
col1 = k
|
||||||
for line in lines:
|
for line in lines:
|
||||||
@ -353,10 +349,7 @@ def print_dict(dct, dict_property="Property", wrap=0):
|
|||||||
v = '-'
|
v = '-'
|
||||||
pt.add_row([k, v])
|
pt.add_row([k, v])
|
||||||
|
|
||||||
if six.PY3:
|
|
||||||
print(encodeutils.safe_encode(pt.get_string()).decode())
|
print(encodeutils.safe_encode(pt.get_string()).decode())
|
||||||
else:
|
|
||||||
print(encodeutils.safe_encode(pt.get_string()))
|
|
||||||
|
|
||||||
|
|
||||||
def get_password(max_password_prompts=3):
|
def get_password(max_password_prompts=3):
|
||||||
@ -366,7 +359,7 @@ def get_password(max_password_prompts=3):
|
|||||||
if hasattr(sys.stdin, "isatty") and sys.stdin.isatty():
|
if hasattr(sys.stdin, "isatty") and sys.stdin.isatty():
|
||||||
# Check for Ctrl-D
|
# Check for Ctrl-D
|
||||||
try:
|
try:
|
||||||
for __ in moves.range(max_password_prompts):
|
for __ in range(max_password_prompts):
|
||||||
pw1 = getpass.getpass("OS Password: ")
|
pw1 = getpass.getpass("OS Password: ")
|
||||||
if verify:
|
if verify:
|
||||||
pw2 = getpass.getpass("Please verify: ")
|
pw2 = getpass.getpass("Please verify: ")
|
||||||
|
@ -24,8 +24,7 @@ from oslo_serialization import jsonutils
|
|||||||
from oslo_utils import encodeutils
|
from oslo_utils import encodeutils
|
||||||
from oslo_utils import importutils
|
from oslo_utils import importutils
|
||||||
import requests
|
import requests
|
||||||
import six
|
from urllib import parse
|
||||||
from six.moves.urllib import parse
|
|
||||||
|
|
||||||
from cyborgclient.common import exceptions as exc
|
from cyborgclient.common import exceptions as exc
|
||||||
from cyborgclient.common import utils
|
from cyborgclient.common import utils
|
||||||
@ -137,7 +136,7 @@ class HTTPClient(object):
|
|||||||
dump.append('')
|
dump.append('')
|
||||||
if resp.content:
|
if resp.content:
|
||||||
content = resp.content
|
content = resp.content
|
||||||
if isinstance(content, six.binary_type):
|
if isinstance(content, bytes):
|
||||||
content = content.decode()
|
content = content.decode()
|
||||||
dump.extend([content, ''])
|
dump.extend([content, ''])
|
||||||
LOG.debug('\n'.join(dump))
|
LOG.debug('\n'.join(dump))
|
||||||
|
@ -16,16 +16,18 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import copy
|
import copy
|
||||||
|
import io
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import socket
|
import socket
|
||||||
import ssl
|
import ssl
|
||||||
|
import urllib.parse as urlparse
|
||||||
|
|
||||||
|
from http import client as http_client
|
||||||
from keystoneauth1 import adapter
|
from keystoneauth1 import adapter
|
||||||
from oslo_utils import importutils
|
from oslo_utils import importutils
|
||||||
import six
|
|
||||||
import six.moves.urllib.parse as urlparse
|
|
||||||
|
|
||||||
from cyborgclient import exceptions
|
from cyborgclient import exceptions
|
||||||
|
|
||||||
@ -93,7 +95,7 @@ class HTTPClient(object):
|
|||||||
_kwargs['key_file'] = kwargs.get('key_file', None)
|
_kwargs['key_file'] = kwargs.get('key_file', None)
|
||||||
_kwargs['insecure'] = kwargs.get('insecure', False)
|
_kwargs['insecure'] = kwargs.get('insecure', False)
|
||||||
elif parts.scheme == 'http':
|
elif parts.scheme == 'http':
|
||||||
_class = six.moves.http_client.HTTPConnection
|
_class = http_client.HTTPConnection
|
||||||
else:
|
else:
|
||||||
msg = 'Unsupported scheme: %s' % parts.scheme
|
msg = 'Unsupported scheme: %s' % parts.scheme
|
||||||
raise exceptions.EndpointException(msg)
|
raise exceptions.EndpointException(msg)
|
||||||
@ -194,7 +196,7 @@ class HTTPClient(object):
|
|||||||
]
|
]
|
||||||
body_str = ''.join(body_list)
|
body_str = ''.join(body_list)
|
||||||
self.log_http_response(resp, body_str)
|
self.log_http_response(resp, body_str)
|
||||||
body_iter = six.StringIO(body_str)
|
body_iter = io.StringIO(body_str)
|
||||||
else:
|
else:
|
||||||
self.log_http_response(resp)
|
self.log_http_response(resp)
|
||||||
|
|
||||||
@ -245,7 +247,7 @@ class HTTPClient(object):
|
|||||||
return self._http_request(url, method, **kwargs)
|
return self._http_request(url, method, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
class VerifiedHTTPSConnection(six.moves.http_client.HTTPSConnection):
|
class VerifiedHTTPSConnection(http_client.HTTPSConnection):
|
||||||
"""httplib-compatibile connection using client-side SSL authentication
|
"""httplib-compatibile connection using client-side SSL authentication
|
||||||
|
|
||||||
:see http://code.activestate.com/recipes/
|
:see http://code.activestate.com/recipes/
|
||||||
@ -254,7 +256,7 @@ class VerifiedHTTPSConnection(six.moves.http_client.HTTPSConnection):
|
|||||||
|
|
||||||
def __init__(self, host, port, key_file=None, cert_file=None,
|
def __init__(self, host, port, key_file=None, cert_file=None,
|
||||||
ca_file=None, timeout=None, insecure=False):
|
ca_file=None, timeout=None, insecure=False):
|
||||||
six.moves.http_client.HTTPSConnection.__init__(self, host, port,
|
http_client.HTTPSConnection.__init__(self, host, port,
|
||||||
key_file=key_file,
|
key_file=key_file,
|
||||||
cert_file=cert_file)
|
cert_file=cert_file)
|
||||||
self.key_file = key_file
|
self.key_file = key_file
|
||||||
|
@ -17,7 +17,7 @@ import inspect
|
|||||||
import sys
|
import sys
|
||||||
|
|
||||||
from oslo_serialization import jsonutils
|
from oslo_serialization import jsonutils
|
||||||
import six
|
|
||||||
|
|
||||||
from cyborgclient.i18n import _
|
from cyborgclient.i18n import _
|
||||||
|
|
||||||
@ -491,14 +491,14 @@ def from_response(response, method, url, message=None, traceback=None):
|
|||||||
# {u'error_message': u'{"debuginfo": null, "faultcode":
|
# {u'error_message': u'{"debuginfo": null, "faultcode":
|
||||||
# "Client", "faultstring": "error message"}'}, the
|
# "Client", "faultstring": "error message"}'}, the
|
||||||
# "error_message" in the body is also a json string.
|
# "error_message" in the body is also a json string.
|
||||||
if isinstance(error, six.string_types):
|
if isinstance(error, str):
|
||||||
error = jsonutils.loads(error)
|
error = jsonutils.loads(error)
|
||||||
|
|
||||||
if hasattr(error, 'keys'):
|
if hasattr(error, 'keys'):
|
||||||
kwargs['message'] = (error.get('message') or
|
kwargs['message'] = (error.get('message') or
|
||||||
error.get('faultstring'))
|
error.get('faultstring'))
|
||||||
kwargs['details'] = (error.get('details') or
|
kwargs['details'] = (error.get('details') or
|
||||||
six.text_type(body))
|
str(body))
|
||||||
elif content_type.startswith("text/"):
|
elif content_type.startswith("text/"):
|
||||||
kwargs["details"] = getattr(response, 'text', '')
|
kwargs["details"] = getattr(response, 'text', '')
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ import sys
|
|||||||
from oslo_utils import encodeutils
|
from oslo_utils import encodeutils
|
||||||
from oslo_utils import importutils
|
from oslo_utils import importutils
|
||||||
from oslo_utils import strutils
|
from oslo_utils import strutils
|
||||||
import six
|
|
||||||
|
|
||||||
profiler = importutils.try_import("osprofiler.profiler")
|
profiler = importutils.try_import("osprofiler.profiler")
|
||||||
|
|
||||||
@ -638,7 +638,7 @@ def main():
|
|||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.debug(e, exc_info=1)
|
logger.debug(e, exc_info=1)
|
||||||
print("ERROR: %s" % encodeutils.safe_encode(six.text_type(e)),
|
print("ERROR: %s" % encodeutils.safe_encode(str(e)),
|
||||||
file=sys.stderr)
|
file=sys.stderr)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user