Merge "Remove six library"

This commit is contained in:
Zuul 2021-10-12 00:55:27 +00:00 committed by Gerrit Code Review
commit c793e9174f
10 changed files with 20 additions and 55 deletions

View File

@ -14,9 +14,9 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import argparse import argparse
from configparser import ConfigParser
import logging import logging
import os import os
import six
import sys import sys
import time import time
@ -27,17 +27,8 @@ from keystoneauth1 import session
from novaclient import client from novaclient import client
from novaclient.exceptions import ClientException from novaclient.exceptions import ClientException
# In python3 SafeConfigParser was renamed to ConfigParser and the default
# for duplicate options default to true. In case of nova it is valid to config = ConfigParser(strict=False)
# have duplicate option lines, e.g. passthrough_whitelist which leads to
# issues reading the nova.conf
# https://bugs.launchpad.net/tripleo/+bug/1827775
if six.PY3:
from six.moves.configparser import ConfigParser
config = ConfigParser(strict=False)
else:
from six.moves.configparser import SafeConfigParser
config = SafeConfigParser()
debug = os.getenv('__OS_DEBUG', 'false') debug = os.getenv('__OS_DEBUG', 'false')

View File

@ -14,9 +14,9 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import argparse import argparse
from configparser import ConfigParser
import logging import logging
import os import os
import six
import socket import socket
import sys import sys
import time import time
@ -27,17 +27,8 @@ from keystoneauth1 import session
from novaclient import client from novaclient import client
# In python3 SafeConfigParser was renamed to ConfigParser and the default
# for duplicate options default to true. In case of nova it is valid to config = ConfigParser(strict=False)
# have duplicate option lines, e.g. passthrough_whitelist which leads to
# issues reading the nova.conf
# https://bugs.launchpad.net/tripleo/+bug/1827775
if six.PY3:
from six.moves.configparser import ConfigParser
config = ConfigParser(strict=False)
else:
from six.moves.configparser import SafeConfigParser
config = SafeConfigParser()
debug = os.getenv('__OS_DEBUG', 'false') debug = os.getenv('__OS_DEBUG', 'false')

View File

@ -17,10 +17,10 @@
# shell script to check if placement API is up after X attempts. # shell script to check if placement API is up after X attempts.
# Default max is 60 iterations with 10s (default) timeout in between. # Default max is 60 iterations with 10s (default) timeout in between.
from configparser import ConfigParser
import logging import logging
import os import os
import re import re
import six
import sys import sys
import time import time
@ -29,18 +29,8 @@ from keystoneauth1 import session
from keystoneclient.v3 import client from keystoneclient.v3 import client
import requests import requests
# In python3 SafeConfigParser was renamed to ConfigParser and the default
# for duplicate options default to true. In case of nova it is valid to
# have duplicate option lines, e.g. passthrough_whitelist which leads to
# issues reading the nova.conf
# https://bugs.launchpad.net/tripleo/+bug/1827775
if six.PY3:
from six.moves.configparser import ConfigParser
config = ConfigParser(strict=False)
else:
from six.moves.configparser import SafeConfigParser
config = SafeConfigParser()
config = ConfigParser(strict=False)
debug = os.getenv('__OS_DEBUG', 'false') debug = os.getenv('__OS_DEBUG', 'false')

View File

@ -18,7 +18,6 @@ from unittest import mock
import contextlib import contextlib
import os import os
from os import stat as orig_stat from os import stat as orig_stat
import six
import stat import stat
import sys import sys
@ -375,7 +374,7 @@ class NovaStatedirOwnershipManagerTestCase(base.BaseTestCase):
# Determine which paths should change uid/gid # Determine which paths should change uid/gid
expected_changes = {} expected_changes = {}
for k, v in six.iteritems(testtree): for k, v in testtree.items():
if k == '/var/lib/nova/upgrade_marker': if k == '/var/lib/nova/upgrade_marker':
# Ignore the marker, it should be deleted # Ignore the marker, it should be deleted
continue continue
@ -394,7 +393,7 @@ class NovaStatedirOwnershipManagerTestCase(base.BaseTestCase):
with fake_testtree(testtree) as (_, _, _, _, fake_unlink, _, _): with fake_testtree(testtree) as (_, _, _, _, fake_unlink, _, _):
NovaStatedirOwnershipManager('/var/lib/nova').run() NovaStatedirOwnershipManager('/var/lib/nova').run()
for fn, expected in six.iteritems(expected_changes): for fn, expected in expected_changes.items():
assert_ids(testtree, fn, expected[0], expected[1]) assert_ids(testtree, fn, expected[0], expected[1])
fake_unlink.assert_called_with('/var/lib/nova/upgrade_marker') fake_unlink.assert_called_with('/var/lib/nova/upgrade_marker')

View File

@ -4,5 +4,4 @@
pbr!=2.1.0,>=2.0.0 # Apache-2.0 pbr!=2.1.0,>=2.0.0 # Apache-2.0
PyYAML>=3.12 # MIT PyYAML>=3.12 # MIT
Jinja2>=2.10 # BSD License (3 clause) Jinja2>=2.10 # BSD License (3 clause)
six>=1.10.0 # MIT
tripleo-common>=7.1.0 # Apache-2.0 tripleo-common>=7.1.0 # Apache-2.0

View File

@ -17,7 +17,6 @@ import datetime
import os import os
import re import re
import shutil import shutil
import six
import sys import sys
import yaml import yaml
@ -140,9 +139,9 @@ class TemplateLoader(yaml.SafeLoader):
return collections.OrderedDict(self.construct_pairs(node)) return collections.OrderedDict(self.construct_pairs(node))
TemplateDumper.add_representer(six.text_type, TemplateDumper.add_representer(str,
TemplateDumper.description_presenter) TemplateDumper.description_presenter)
TemplateDumper.add_representer(six.binary_type, TemplateDumper.add_representer(bytes,
TemplateDumper.description_presenter) TemplateDumper.description_presenter)
TemplateDumper.add_representer(collections.OrderedDict, TemplateDumper.add_representer(collections.OrderedDict,

View File

@ -17,7 +17,6 @@ import datetime
import os import os
import re import re
import shutil import shutil
import six
import subprocess import subprocess
import sys import sys
import yaml import yaml
@ -167,9 +166,9 @@ class TemplateLoader(yaml.SafeLoader):
return collections.OrderedDict(self.construct_pairs(node)) return collections.OrderedDict(self.construct_pairs(node))
TemplateDumper.add_representer(six.text_type, TemplateDumper.add_representer(str,
TemplateDumper.description_presenter) TemplateDumper.description_presenter)
TemplateDumper.add_representer(six.binary_type, TemplateDumper.add_representer(bytes,
TemplateDumper.description_presenter) TemplateDumper.description_presenter)
TemplateDumper.add_representer(collections.OrderedDict, TemplateDumper.add_representer(collections.OrderedDict,

View File

@ -15,7 +15,6 @@ import argparse
import jinja2 import jinja2
import os import os
import shutil import shutil
import six
import sys import sys
import yaml import yaml
@ -33,7 +32,7 @@ def _shutil_copy_if_not_same(src, dst):
try: try:
shutil.copy(src, dst) shutil.copy(src, dst)
except Exception as ex: except Exception as ex:
if 'are the same file' in six.text_type(ex): if 'are the same file' in str(ex):
pass pass
else: else:
raise raise
@ -98,7 +97,7 @@ def _j2_render_to_file(j2_template, j2_data, outfile_name=None,
r_template = template.render(**j2_data) r_template = template.render(**j2_data)
except jinja2.exceptions.TemplateError as ex: except jinja2.exceptions.TemplateError as ex:
error_msg = ("Error rendering template %s : %s" error_msg = ("Error rendering template %s : %s"
% (yaml_f, six.text_type(ex))) % (yaml_f, str(ex)))
print(error_msg) print(error_msg)
raise Exception(error_msg) raise Exception(error_msg)
if not dry_run: if not dry_run:

View File

@ -15,7 +15,6 @@ import argparse
import glob import glob
import os import os
import re import re
import six
import sys import sys
import traceback import traceback
import yaml import yaml
@ -24,7 +23,7 @@ from copy import copy
def is_string(value): def is_string(value):
return isinstance(value, six.string_types) return isinstance(value, str)
# Only permit the template alias versions. # Only permit the template alias versions.

View File

@ -17,7 +17,6 @@ import tempfile
from unittest import mock from unittest import mock
from oslotest import base from oslotest import base
import six
import testscenarios import testscenarios
from tripleo_heat_templates import environment_generator from tripleo_heat_templates import environment_generator
@ -727,8 +726,8 @@ resource_registry:
cls.content_scenarios) cls.content_scenarios)
def test_generator(self): def test_generator(self):
fake_input = io.StringIO(six.text_type(self.input_file)) fake_input = io.StringIO(str(self.input_file))
fake_template = io.StringIO(six.text_type(self.template)) fake_template = io.StringIO(str(self.template))
_, fake_output_path = tempfile.mkstemp() _, fake_output_path = tempfile.mkstemp()
fake_output = open(fake_output_path, 'w') fake_output = open(fake_output_path, 'w')
with mock.patch('tripleo_heat_templates.environment_generator.open', with mock.patch('tripleo_heat_templates.environment_generator.open',
@ -740,7 +739,7 @@ resource_registry:
if self.nested_output: if self.nested_output:
_, fake_nested_output_path = tempfile.mkstemp() _, fake_nested_output_path = tempfile.mkstemp()
fake_nested_output = open(fake_nested_output_path, 'w') fake_nested_output = open(fake_nested_output_path, 'w')
fake_template2 = io.StringIO(six.text_type(self.template)) fake_template2 = io.StringIO(str(self.template))
mock_se = [fake_input, fake_template, fake_output, mock_se = [fake_input, fake_template, fake_output,
fake_template2, fake_nested_output] fake_template2, fake_nested_output]
mock_open.side_effect = mock_se mock_open.side_effect = mock_se