Remove Python 2 support
Python 2 has been deprecated. This patch removes all traces of six, unicode strings and Python 2 tweaks. Change-Id: Ie6d62561fdaede0496052aa884021faa1927d5b8
This commit is contained in:
parent
6b0409043f
commit
8f8e9fde6c
|
@ -36,7 +36,7 @@ source_suffix = '.rst'
|
|||
master_doc = 'index'
|
||||
|
||||
# General information about the project.
|
||||
copyright = u'2015, Sahara team'
|
||||
copyright = '2015, Sahara team'
|
||||
|
||||
# The language for content autogenerated by Sphinx. Refer to documentation
|
||||
# for a list of supported languages.
|
||||
|
@ -153,8 +153,8 @@ htmlhelp_basename = 'saharacdhplugin-testsdoc'
|
|||
# Grouping the document tree into LaTeX files. List of tuples
|
||||
# (source start file, target name, title, author, documentclass [howto/manual]).
|
||||
latex_documents = [
|
||||
('index', 'doc-sahara-plugin-cdh.tex', u'Sahara CDH Plugin Documentation',
|
||||
u'Sahara team', 'manual'),
|
||||
('index', 'doc-sahara-plugin-cdh.tex', 'Sahara CDH Plugin Documentation',
|
||||
'Sahara team', 'manual'),
|
||||
]
|
||||
|
||||
# The name of an image file (relative to this directory) to place at the top of
|
||||
|
@ -184,8 +184,8 @@ smartquotes_excludes = {'builders': ['latex']}
|
|||
# One entry per manual page. List of tuples
|
||||
# (source start file, name, description, authors, manual section).
|
||||
man_pages = [
|
||||
('index', 'sahara-plugin-cdh', u'sahara-plugin-cdh Documentation',
|
||||
[u'Sahara team'], 1)
|
||||
('index', 'sahara-plugin-cdh', 'sahara-plugin-cdh Documentation',
|
||||
['Sahara team'], 1)
|
||||
]
|
||||
|
||||
# If true, show URL addresses after external links.
|
||||
|
@ -198,8 +198,8 @@ man_pages = [
|
|||
# (source start file, target name, title, author,
|
||||
# dir menu entry, description, category)
|
||||
texinfo_documents = [
|
||||
('index', 'sahara-plugin-cdh', u'sahara-plugin-cdh Documentation',
|
||||
u'Sahara team', 'sahara-plugin-cdh', 'One line description of project.',
|
||||
('index', 'sahara-plugin-cdh', 'sahara-plugin-cdh Documentation',
|
||||
'Sahara team', 'sahara-plugin-cdh', 'One line description of project.',
|
||||
'Miscellaneous'),
|
||||
]
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ source_suffix = '.rst'
|
|||
master_doc = 'index'
|
||||
|
||||
# General information about the project.
|
||||
copyright = u'2015, Sahara Developers'
|
||||
copyright = '2015, Sahara Developers'
|
||||
|
||||
# Release do not need a version number in the title, they
|
||||
# cover multiple versions.
|
||||
|
@ -142,8 +142,8 @@ htmlhelp_basename = 'SaharaCDHReleaseNotesdoc'
|
|||
# author, documentclass [howto, manual, or own class]).
|
||||
latex_documents = [
|
||||
('index', 'SaharaCDHReleaseNotes.tex',
|
||||
u'Sahara CDH Plugin Release Notes Documentation',
|
||||
u'Sahara Developers', 'manual'),
|
||||
'Sahara CDH Plugin Release Notes Documentation',
|
||||
'Sahara Developers', 'manual'),
|
||||
]
|
||||
|
||||
# The name of an image file (relative to this directory) to place at the top of
|
||||
|
@ -173,8 +173,8 @@ latex_documents = [
|
|||
# (source start file, name, description, authors, manual section).
|
||||
man_pages = [
|
||||
('index', 'saharacdhreleasenotes',
|
||||
u'Sahara CDH Plugin Release Notes Documentation',
|
||||
[u'Sahara Developers'], 1)
|
||||
'Sahara CDH Plugin Release Notes Documentation',
|
||||
['Sahara Developers'], 1)
|
||||
]
|
||||
|
||||
# If true, show URL addresses after external links.
|
||||
|
@ -188,8 +188,8 @@ man_pages = [
|
|||
# dir menu entry, description, category)
|
||||
texinfo_documents = [
|
||||
('index', 'SaharaCDHReleaseNotes',
|
||||
u'Sahara CDH Plugin Release Notes Documentation',
|
||||
u'Sahara Developers', 'SaharaCDHReleaseNotes',
|
||||
'Sahara CDH Plugin Release Notes Documentation',
|
||||
'Sahara Developers', 'SaharaCDHReleaseNotes',
|
||||
'One line description of project.',
|
||||
'Miscellaneous'),
|
||||
]
|
||||
|
|
|
@ -16,4 +16,3 @@ oslo.serialization!=2.19.1,>=2.18.0 # Apache-2.0
|
|||
oslo.utils>=3.33.0 # Apache-2.0
|
||||
requests>=2.14.2 # Apache-2.0
|
||||
sahara>=10.0.0.0b1
|
||||
six>=1.10.0 # MIT
|
||||
|
|
|
@ -15,8 +15,6 @@
|
|||
|
||||
import abc
|
||||
|
||||
import six
|
||||
|
||||
from sahara.plugins import conductor
|
||||
from sahara.plugins import context
|
||||
from sahara.plugins import kerberos
|
||||
|
@ -24,8 +22,7 @@ from sahara_plugin_cdh.plugins.cdh import db_helper as dh
|
|||
from sahara_plugin_cdh.plugins.cdh import health
|
||||
|
||||
|
||||
@six.add_metaclass(abc.ABCMeta)
|
||||
class AbstractVersionHandler(object):
|
||||
class AbstractVersionHandler(object, metaclass=abc.ABCMeta):
|
||||
|
||||
@abc.abstractmethod
|
||||
def get_node_processes(self):
|
||||
|
|
|
@ -22,12 +22,12 @@
|
|||
# To satisfy the pep8 and python3 tests, we did some changes to the codes.
|
||||
# We also change some importings to use Sahara inherited classes.
|
||||
|
||||
import http.cookiejar
|
||||
import posixpath
|
||||
import urllib
|
||||
|
||||
from oslo_log import log as logging
|
||||
from oslo_serialization import jsonutils as json
|
||||
import six
|
||||
from six.moves import urllib
|
||||
|
||||
from sahara_plugin_cdh.plugins.cdh import exceptions as ex
|
||||
|
||||
|
@ -53,7 +53,7 @@ class HttpClient(object):
|
|||
authhandler = urllib.request.HTTPBasicAuthHandler(self._passmgr)
|
||||
|
||||
# Make a cookie processor
|
||||
cookiejar = six.moves.http_cookiejar.CookieJar()
|
||||
cookiejar = http.cookiejar.CookieJar()
|
||||
|
||||
self._opener = urllib.request.build_opener(
|
||||
urllib.request.HTTPErrorProcessor(),
|
||||
|
@ -130,7 +130,7 @@ class HttpClient(object):
|
|||
try:
|
||||
return self._opener.open(request)
|
||||
except urllib.error.HTTPError as ex:
|
||||
message = six.text_type(ex)
|
||||
message = str(ex)
|
||||
try:
|
||||
json_body = json.loads(message)
|
||||
message = json_body['message']
|
||||
|
|
|
@ -27,8 +27,7 @@ import socket
|
|||
|
||||
from oslo_log import log as logging
|
||||
from oslo_serialization import jsonutils as json
|
||||
import six
|
||||
from six.moves import urllib
|
||||
import urllib
|
||||
|
||||
from sahara.plugins import context
|
||||
from sahara_plugin_cdh.i18n import _
|
||||
|
@ -80,7 +79,7 @@ class Resource(object):
|
|||
except Exception as ex:
|
||||
raise ex.CMApiException(
|
||||
_("Command %(method)s %(path)s failed: %(msg)s")
|
||||
% {'method': method, 'path': path, 'msg': six.text_type(ex)})
|
||||
% {'method': method, 'path': path, 'msg': str(ex)})
|
||||
|
||||
LOG.debug("{method} got response: {body}".format(method=method,
|
||||
body=body[:32]))
|
||||
|
@ -105,13 +104,13 @@ class Resource(object):
|
|||
|
||||
:return: A dictionary of the JSON result.
|
||||
"""
|
||||
for retry in six.moves.xrange(self.retries + 1):
|
||||
for retry in range(self.retries + 1):
|
||||
if retry:
|
||||
context.sleep(self.retry_sleep)
|
||||
try:
|
||||
return self.invoke("GET", relpath, params)
|
||||
except (socket.error, urllib.error.URLError) as e:
|
||||
if "timed out" in six.text_type(e).lower():
|
||||
if "timed out" in str(e).lower():
|
||||
if retry < self.retries:
|
||||
LOG.warning("Timeout issuing GET request for "
|
||||
"{path}. Will retry".format(
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
# We also change some importings to use Sahara inherited classes.
|
||||
|
||||
from oslo_serialization import jsonutils as json
|
||||
import six
|
||||
|
||||
from sahara_plugin_cdh.plugins.cdh.client import role_config_groups
|
||||
from sahara_plugin_cdh.plugins.cdh.client import roles
|
||||
|
@ -193,7 +192,7 @@ class ApiService(types.BaseApiResource):
|
|||
data = {}
|
||||
if rt_configs:
|
||||
rt_list = []
|
||||
for rt, cfg in six.iteritems(rt_configs):
|
||||
for rt, cfg in rt_configs.items():
|
||||
rt_data = types.config_to_api_list(cfg)
|
||||
rt_data['roleType'] = rt
|
||||
rt_list.append(rt_data)
|
||||
|
|
|
@ -28,7 +28,6 @@ import time
|
|||
|
||||
from oslo_serialization import jsonutils as json
|
||||
from oslo_utils import reflection
|
||||
import six
|
||||
|
||||
from sahara.plugins import context
|
||||
from sahara_plugin_cdh.i18n import _
|
||||
|
@ -204,7 +203,7 @@ class BaseApiObject(object):
|
|||
# We use unicode strings as keys in kwargs.
|
||||
str_attrs = {}
|
||||
if attrs:
|
||||
for k, v in six.iteritems(attrs):
|
||||
for k, v in attrs.items():
|
||||
if k not in ('self', 'resource_root'):
|
||||
str_attrs[k] = v
|
||||
BaseApiObject.__init__(obj, resource_root, **str_attrs)
|
||||
|
@ -222,7 +221,7 @@ class BaseApiObject(object):
|
|||
"""
|
||||
self._resource_root = resource_root
|
||||
|
||||
for name, attr in six.iteritems(self._get_attributes()):
|
||||
for name, attr in self._get_attributes().items():
|
||||
object.__setattr__(self, name, None)
|
||||
if attrs:
|
||||
self._set_attrs(attrs, from_json=False)
|
||||
|
@ -234,7 +233,7 @@ class BaseApiObject(object):
|
|||
read-only attributes (e.g. when deserializing from JSON) and skipping
|
||||
JSON deserialization of values.
|
||||
"""
|
||||
for k, v in six.iteritems(attrs):
|
||||
for k, v in attrs.items():
|
||||
attr = self._check_attr(k, allow_ro)
|
||||
if attr and from_json:
|
||||
v = attr.from_json(self._get_resource_root(), v)
|
||||
|
@ -279,7 +278,7 @@ class BaseApiObject(object):
|
|||
|
||||
def to_json_dict(self, preserve_ro=False):
|
||||
dic = {}
|
||||
for name, attr in six.iteritems(self._get_attributes()):
|
||||
for name, attr in self._get_attributes().items():
|
||||
if not preserve_ro and attr and not attr.rw:
|
||||
continue
|
||||
try:
|
||||
|
@ -647,7 +646,7 @@ def config_to_api_list(dic):
|
|||
:return: JSON dictionary of an ApiConfig list (*not* an ApiList).
|
||||
"""
|
||||
config = []
|
||||
for k, v in six.iteritems(dic):
|
||||
for k, v in dic.items():
|
||||
config.append({'name': k, 'value': v})
|
||||
return {ApiList.LIST_KEY: config}
|
||||
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
|
||||
import functools
|
||||
|
||||
import six
|
||||
|
||||
from sahara.plugins import context
|
||||
from sahara.plugins import exceptions as ex
|
||||
|
@ -474,7 +473,7 @@ class ClouderaUtils(object):
|
|||
'HDFS_GATEWAY': ['HDFS_NAMENODE', 'HDFS_DATANODE',
|
||||
"HDFS_SECONDARYNAMENODE"]
|
||||
}
|
||||
for extra_role in six.iterkeys(extra_roles):
|
||||
for extra_role in extra_roles.keys():
|
||||
valid_processes = extra_roles[extra_role]
|
||||
for valid in valid_processes:
|
||||
if valid in current:
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
import functools
|
||||
|
||||
from oslo_log import log as logging
|
||||
import six
|
||||
|
||||
from sahara.plugins import health_check_base
|
||||
from sahara_plugin_cdh.i18n import _
|
||||
|
@ -70,7 +69,7 @@ class HealthStatusProvider(object):
|
|||
LOG.exception(msg)
|
||||
self._exception_store = _(
|
||||
"%(problem)s, reason: %(reason)s") % {
|
||||
'problem': msg, 'reason': six.text_type(e)}
|
||||
'problem': msg, 'reason': str(e)}
|
||||
|
||||
|
||||
class ClouderaManagerHealthCheck(health_check_base.BasicHealthCheck):
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
# limitations under the License.
|
||||
|
||||
from oslo_serialization import jsonutils as json
|
||||
import six
|
||||
|
||||
from sahara_plugin_cdh.plugins.cdh.client import api_client
|
||||
|
||||
|
@ -65,7 +64,7 @@ def process_service(service, service_name):
|
|||
|
||||
def parse_config(config):
|
||||
cfg = []
|
||||
for name, value in six.iteritems(config):
|
||||
for name, value in config.items():
|
||||
p = {
|
||||
'name': value.name,
|
||||
'value': value.default,
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
# limitations under the License.
|
||||
|
||||
from oslo_serialization import jsonutils as json
|
||||
import six
|
||||
|
||||
from sahara_plugin_cdh.plugins.cdh.client import api_client
|
||||
|
||||
|
@ -65,7 +64,7 @@ def process_service(service, service_name):
|
|||
|
||||
def parse_config(config):
|
||||
cfg = []
|
||||
for name, value in six.iteritems(config):
|
||||
for name, value in config.items():
|
||||
p = {
|
||||
'name': value.name,
|
||||
'value': value.default,
|
||||
|
|
|
@ -15,8 +15,6 @@
|
|||
|
||||
import itertools
|
||||
|
||||
import six
|
||||
|
||||
from sahara.plugins import exceptions as ex
|
||||
from sahara.plugins import testutils as tu
|
||||
from sahara_plugin_cdh.tests.unit import base
|
||||
|
@ -35,7 +33,7 @@ def make_ng_dict_with_inst(counter, name, flavor, processes, count,
|
|||
if not instances:
|
||||
instances = []
|
||||
for i in range(count):
|
||||
n = six.next(counter)
|
||||
n = next(counter)
|
||||
instance = tu.make_inst_dict("id{0}".format(n),
|
||||
"fake_inst{0}".format(n),
|
||||
management_ip='1.2.3.{0}'.format(n))
|
||||
|
@ -87,9 +85,9 @@ def get_fake_cluster_with_process(processes=None,
|
|||
wkrs_ng[2].remove(process)
|
||||
|
||||
other_ng_list = []
|
||||
for process, count in six.iteritems(processes):
|
||||
for process, count in processes.items():
|
||||
if count:
|
||||
ng = ('service_ng{0}'.format(six.next(ng_counter)),
|
||||
ng = ('service_ng{0}'.format(next(ng_counter)),
|
||||
1, [process], count)
|
||||
other_ng_list.append(ng)
|
||||
|
||||
|
@ -97,7 +95,7 @@ def get_fake_cluster_with_process(processes=None,
|
|||
|
||||
ng_dict_list = [make_ng_dict_with_inst(
|
||||
inst_counter, *args,
|
||||
id="ng_id{0}".format(six.next(ng_id_counter)))
|
||||
id="ng_id{0}".format(next(ng_id_counter)))
|
||||
for args in ng_list]
|
||||
|
||||
return tu.create_cluster('test_cluster', 1, 'cdh',
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
|
||||
from unittest import mock
|
||||
|
||||
import six
|
||||
import testtools
|
||||
|
||||
from sahara.plugins import health_check_base as base_health
|
||||
|
@ -49,7 +48,7 @@ class TestHealthCheck(unit_base.SaharaTestCase):
|
|||
msg = "%s%s" % (msg, postfix)
|
||||
all_message = "Cluster health is %(col)s. Reason: %(msg)s" % {
|
||||
'col': col, 'msg': msg}
|
||||
self.assertEqual(all_message, six.text_type(e))
|
||||
self.assertEqual(all_message, str(e))
|
||||
raise
|
||||
|
||||
@mock.patch('sahara_plugin_cdh.plugins.cdh.health.HealthStatusProvider.'
|
||||
|
|
|
@ -15,8 +15,6 @@
|
|||
|
||||
from unittest import mock
|
||||
|
||||
import six
|
||||
|
||||
from sahara.plugins import base as pb
|
||||
from sahara_plugin_cdh.plugins.cdh.v5_11_0 import edp_engine
|
||||
from sahara_plugin_cdh.plugins.cdh.v5_11_0 import versionhandler
|
||||
|
@ -37,7 +35,7 @@ class VersionHandlerTestCase(base.SaharaTestCase):
|
|||
|
||||
def test_get_node_processes(self):
|
||||
processes = self.vh.get_node_processes()
|
||||
for k, v in six.iteritems(processes):
|
||||
for k, v in processes.items():
|
||||
for p in v:
|
||||
self.assertIsInstance(p, str)
|
||||
|
||||
|
|
|
@ -15,8 +15,6 @@
|
|||
|
||||
from unittest import mock
|
||||
|
||||
import six
|
||||
|
||||
from sahara.plugins import base as pb
|
||||
from sahara_plugin_cdh.plugins.cdh.v5_7_0 import edp_engine
|
||||
from sahara_plugin_cdh.plugins.cdh.v5_7_0 import versionhandler
|
||||
|
@ -37,7 +35,7 @@ class VersionHandlerTestCase(base.SaharaTestCase):
|
|||
|
||||
def test_get_node_processes(self):
|
||||
processes = self.vh.get_node_processes()
|
||||
for k, v in six.iteritems(processes):
|
||||
for k, v in processes.items():
|
||||
for p in v:
|
||||
self.assertIsInstance(p, str)
|
||||
|
||||
|
|
|
@ -15,8 +15,6 @@
|
|||
|
||||
from unittest import mock
|
||||
|
||||
import six
|
||||
|
||||
from sahara.plugins import base as pb
|
||||
from sahara_plugin_cdh.plugins.cdh.v5_9_0 import edp_engine
|
||||
from sahara_plugin_cdh.plugins.cdh.v5_9_0 import versionhandler
|
||||
|
@ -37,7 +35,7 @@ class VersionHandlerTestCase(base.SaharaTestCase):
|
|||
|
||||
def test_get_node_processes(self):
|
||||
processes = self.vh.get_node_processes()
|
||||
for k, v in six.iteritems(processes):
|
||||
for k, v in processes.items():
|
||||
for p in v:
|
||||
self.assertIsInstance(p, str)
|
||||
|
||||
|
|
Loading…
Reference in New Issue