Remove six

The Python 2.7 Support has been support
So remove hacking rules for compatibility between python 2 and 3

Change-Id: Ia0fe869b80d330551cc9dac06c23001faf229542
This commit is contained in:
likui 2020-10-19 17:21:55 +08:00 committed by Rico Lin
parent 89d2a912d6
commit 7b525d8eeb
7 changed files with 14 additions and 18 deletions

View File

@ -16,7 +16,6 @@ import json
import logging
import os
import shutil
import six
import subprocess
import sys
@ -41,7 +40,7 @@ def prepare_dir(path):
def run_subproc(fn, **kwargs):
env = os.environ.copy()
for k, v in kwargs.items():
env[six.text_type(k)] = v
env[str(k)] = v
try:
subproc = subprocess.Popen(fn, stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
@ -49,7 +48,7 @@ def run_subproc(fn, **kwargs):
stdout, stderr = subproc.communicate()
except OSError as exc:
ret = -1
stderr = six.text_type(exc)
stderr = str(exc)
stdout = ""
else:
ret = subproc.returncode

View File

@ -16,7 +16,6 @@ import ast
import json
import logging
import os
import six
import subprocess
import sys
import yaml
@ -88,7 +87,7 @@ def main(argv=sys.argv):
value = c.get('env_file', None)
if isinstance(value, list):
compose_env_files.extend(value)
elif isinstance(value, six.string_types):
elif isinstance(value, str):
compose_env_files.extend([value])
input_env_files = {}

View File

@ -12,11 +12,11 @@
# License for the specific language governing permissions and limitations
# under the License.
import io
import json
import logging
import os
import re
import six
import sys
import time
@ -81,13 +81,13 @@ def configure_logging():
handler.setFormatter(formatter)
log.addHandler(handler)
deploy_stdout = six.StringIO()
deploy_stdout = io.StringIO()
handler = logging.StreamHandler(deploy_stdout)
handler.setFormatter(formatter)
handler.setLevel('DEBUG')
log.addHandler(handler)
deploy_stderr = six.StringIO()
deploy_stderr = io.StringIO()
handler = logging.StreamHandler(deploy_stderr)
handler.setFormatter(formatter)
handler.setLevel('WARN')
@ -149,7 +149,7 @@ def wait_required_containers(client, log,
waiting_for = dict((v, re.compile(v)) for v in patterns)
while waiting_for:
for name in containers_names(client.containers()):
for k, v in six.iteritems(waiting_for):
for k, v in waiting_for.items():
if v.match(name):
log.info('Pattern %s matches: %s' % (k, name))
del(waiting_for[k])

View File

@ -20,7 +20,6 @@ import stat
import subprocess
import sys
import six
import yaml
# legacy groups that have never had a hook script
@ -109,7 +108,7 @@ def invoke_hook(c, log):
hot_inputs = c.get('inputs', [])
for hot_input in hot_inputs:
if hot_input.get('type', None) == 'String' and \
not isinstance(hot_input['value'], six.string_types):
not isinstance(hot_input['value'], str):
hot_input['value'] = str(hot_input['value'])
iv = dict((i['name'], i['value']) for i in c['inputs'])
# The group property indicates whether it is softwarecomponent or

View File

@ -15,7 +15,6 @@ import copy
import json
import os
import shutil
import six
import tempfile
import fixtures
@ -238,7 +237,7 @@ class HeatConfigTest(common.RunScriptTest):
notify_data = self.json_from_file(notify_file)
self.assertEqual(
self.outputs[hook]['deploy_status_code'],
six.text_type(notify_data['deploy_status_code']))
str(notify_data['deploy_status_code']))
self.assertIn(
self.outputs[hook]['deploy_stderr'],
notify_data['deploy_stderr'])

View File

@ -12,11 +12,11 @@
# under the License.
import copy
import io
import json
import tempfile
import fixtures
import six
from unittest import mock
from tests import common
@ -80,7 +80,7 @@ class HeatConfigNotifyTest(common.RunScriptTest):
super(HeatConfigNotifyTest, self).setUp()
self.deployed_dir = self.useFixture(fixtures.TempDir())
hcn.init_logging = mock.MagicMock()
self.stdin = six.StringIO()
self.stdin = io.StringIO()
def write_config_file(self, data):
config_file = tempfile.NamedTemporaryFile(mode='w')

View File

@ -13,9 +13,9 @@
import copy
import importlib
import io
import json
import logging
import six
import sys
from multiprocessing import Lock
@ -69,8 +69,8 @@ class HookChefTest(common.RunScriptTest):
__file__,
'..',
'heat-config-chef/install.d/hook-chef.py')
sys.stdin = six.StringIO()
sys.stdout = six.StringIO()
sys.stdin = io.StringIO()
sys.stdout = io.StringIO()
def tearDown(self):
super(HookChefTest, self).tearDown()