Remove Python 2 support

Python 2 has been deprecated. This patch removes all
traces of six, unicode strings and Python 2 tweaks.

Change-Id: I9d6fa7b57824cc8480dc7f3728d3abfae2b032da
This commit is contained in:
anguoming 2022-08-13 11:15:15 +08:00
parent d93365f151
commit 500babec2a
11 changed files with 32 additions and 43 deletions

View File

@ -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.
@ -154,8 +154,8 @@ htmlhelp_basename = 'saharavanillaplugin-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-vanilla.tex', u'Sahara Vanilla Plugin Documentation',
u'Sahara team', 'manual'),
('index', 'doc-sahara-plugin-vanilla.tex', 'Sahara Vanilla Plugin Documentation',
'Sahara team', 'manual'),
]
# The name of an image file (relative to this directory) to place at the top of
@ -185,8 +185,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-vanilla', u'sahara-plugin-vanilla Documentation',
[u'Sahara team'], 1)
('index', 'sahara-plugin-vanilla', 'sahara-plugin-vanilla Documentation',
['Sahara team'], 1)
]
# If true, show URL addresses after external links.
@ -199,8 +199,8 @@ man_pages = [
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
('index', 'sahara-plugin-vanilla', u'sahara-plugin-vanilla Documentation',
u'Sahara team', 'sahara-plugin-vanilla', 'One line description of project.',
('index', 'sahara-plugin-vanilla', 'sahara-plugin-vanilla Documentation',
'Sahara team', 'sahara-plugin-vanilla', 'One line description of project.',
'Miscellaneous'),
]

View File

@ -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 = 'SaharaVanillaReleaseNotesdoc'
# author, documentclass [howto, manual, or own class]).
latex_documents = [
('index', 'SaharaVanillaReleaseNotes.tex',
u'Sahara Vanilla Plugin Release Notes Documentation',
u'Sahara Developers', 'manual'),
'Sahara Vanilla 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', 'saharavanillareleasenotes',
u'Sahara Vanilla Plugin Release Notes Documentation',
[u'Sahara Developers'], 1)
'Sahara Vanilla 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', 'SaharaVanillaReleaseNotes',
u'Sahara Vanilla Plugin Release Notes Documentation',
u'Sahara Developers', 'SaharaVanillaReleaseNotes',
'Sahara Vanilla Plugin Release Notes Documentation',
'Sahara Developers', 'SaharaVanillaReleaseNotes',
'One line description of project.',
'Miscellaneous'),
]

View File

@ -15,11 +15,8 @@
import abc
import six
@six.add_metaclass(abc.ABCMeta)
class AbstractVersionHandler(object):
class AbstractVersionHandler(object, metaclass=abc.ABCMeta):
@abc.abstractmethod
def get_node_processes(self):

View File

@ -16,7 +16,6 @@ import os
from oslo_config import cfg
from oslo_log import log as logging
import six
from sahara.plugins import castellan_utils as key_manager
from sahara.plugins import context
@ -315,8 +314,8 @@ def _get_user_configs(pctx, node_group):
def _separate_configs(configs, all_env_configs):
xml_configs = {}
env_configs = {}
for service, params in six.iteritems(configs):
for param, value in six.iteritems(params):
for service, params in configs.items():
for param, value in params.items():
if all_env_configs.get(service, {}).get(param):
if not env_configs.get(service):
env_configs[service] = {}
@ -331,7 +330,7 @@ def _separate_configs(configs, all_env_configs):
def _generate_xml(configs):
xml_confs = {}
for service, confs in six.iteritems(configs):
for service, confs in configs.items():
xml_confs[service] = utils.create_hadoop_xml(confs)
return xml_confs
@ -383,7 +382,7 @@ def _push_xml_configs(instance, configs):
'Hive': '%s/hive-site.xml' % HIVE_CONF_DIR
}
xml_confs = {}
for service, confs in six.iteritems(xmls):
for service, confs in xmls.items():
if service not in service_to_conf_map.keys():
continue
@ -396,7 +395,7 @@ def _push_configs_to_instance(instance, configs):
LOG.debug("Push configs to instance {instance}".format(
instance=instance.instance_name))
with instance.remote() as r:
for fl, data in six.iteritems(configs):
for fl, data in configs.items():
r.write_file_to(fl, data, run_as_root=True)

View File

@ -14,7 +14,6 @@
# limitations under the License.
from oslo_config import cfg
import six
from sahara.plugins import exceptions as ex
from sahara.plugins import provisioning as p
@ -152,7 +151,7 @@ PRIORITY_1_CONFS += CLUSTER_WIDE_CONFS
def init_xml_configs(xml_confs):
configs = []
for service, config_lists in six.iteritems(xml_confs):
for service, config_lists in xml_confs.items():
for config_list in config_lists:
for config in config_list:
if config['name'] not in HIDDEN_CONFS:
@ -212,8 +211,8 @@ DATANODES_STARTUP_TIMEOUT = p.Config(
def init_env_configs(env_confs):
configs = []
for service, config_items in six.iteritems(env_confs):
for name, value in six.iteritems(config_items):
for service, config_items in env_confs.items():
for name, value in config_items.items():
configs.append(p.Config(name, service, "node",
default_value=value, priority=1,
config_type="int"))

View File

@ -16,7 +16,6 @@
import copy
from oslo_config import cfg
import six
from sahara.plugins import provisioning as p
from sahara.plugins import utils
@ -116,7 +115,7 @@ def _get_spark_opt_default(opt_name):
def _get_spark_configs():
spark_configs = []
for service, config_items in six.iteritems(SPARK_CONFS):
for service, config_items in SPARK_CONFS.items():
for item in config_items['OPTIONS']:
cfg = p.Config(name=item["name"],
description=item["description"],
@ -130,7 +129,7 @@ def _get_spark_configs():
def _get_zookeeper_configs():
zk_configs = []
for service, config_items in six.iteritems(config_helper.ZOOKEEPER_CONFS):
for service, config_items in config_helper.ZOOKEEPER_CONFS.items():
for item in config_items['OPTIONS']:
cfg = p.Config(name=item["name"],
description=item["description"],

View File

@ -16,7 +16,6 @@
import copy
from oslo_config import cfg
import six
from sahara.plugins import provisioning as p
from sahara.plugins import utils
@ -116,7 +115,7 @@ def _get_spark_opt_default(opt_name):
def _get_spark_configs():
spark_configs = []
for service, config_items in six.iteritems(SPARK_CONFS):
for service, config_items in SPARK_CONFS.items():
for item in config_items['OPTIONS']:
cfg = p.Config(name=item["name"],
description=item["description"],
@ -130,7 +129,7 @@ def _get_spark_configs():
def _get_zookeeper_configs():
zk_configs = []
for service, config_items in six.iteritems(config_helper.ZOOKEEPER_CONFS):
for service, config_items in config_helper.ZOOKEEPER_CONFS.items():
for item in config_items['OPTIONS']:
cfg = p.Config(name=item["name"],
description=item["description"],

View File

@ -16,7 +16,6 @@
import copy
from oslo_config import cfg
import six
from sahara.plugins import provisioning as p
from sahara.plugins import utils
@ -116,7 +115,7 @@ def _get_spark_opt_default(opt_name):
def _get_spark_configs():
spark_configs = []
for service, config_items in six.iteritems(SPARK_CONFS):
for service, config_items in SPARK_CONFS.items():
for item in config_items['OPTIONS']:
cfg = p.Config(name=item["name"],
description=item["description"],
@ -130,7 +129,7 @@ def _get_spark_configs():
def _get_zookeeper_configs():
zk_configs = []
for service, config_items in six.iteritems(config_helper.ZOOKEEPER_CONFS):
for service, config_items in config_helper.ZOOKEEPER_CONFS.items():
for item in config_items['OPTIONS']:
cfg = p.Config(name=item["name"],
description=item["description"],

View File

@ -15,7 +15,6 @@
from unittest import mock
import six
import testtools
from sahara.plugins import base as pb
@ -55,7 +54,7 @@ class VersionHandlerTest(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)

View File

@ -15,7 +15,6 @@
from unittest import mock
import six
import testtools
from sahara.plugins import base as pb
@ -55,7 +54,7 @@ class VersionHandlerTest(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)

View File

@ -15,7 +15,6 @@
from unittest import mock
import six
import testtools
from sahara.plugins import exceptions as ex
@ -52,7 +51,7 @@ class VersionHandlerTest(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)