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:
parent
89d2a912d6
commit
7b525d8eeb
@ -16,7 +16,6 @@ import json
|
|||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
import six
|
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
@ -41,7 +40,7 @@ def prepare_dir(path):
|
|||||||
def run_subproc(fn, **kwargs):
|
def run_subproc(fn, **kwargs):
|
||||||
env = os.environ.copy()
|
env = os.environ.copy()
|
||||||
for k, v in kwargs.items():
|
for k, v in kwargs.items():
|
||||||
env[six.text_type(k)] = v
|
env[str(k)] = v
|
||||||
try:
|
try:
|
||||||
subproc = subprocess.Popen(fn, stdout=subprocess.PIPE,
|
subproc = subprocess.Popen(fn, stdout=subprocess.PIPE,
|
||||||
stderr=subprocess.PIPE,
|
stderr=subprocess.PIPE,
|
||||||
@ -49,7 +48,7 @@ def run_subproc(fn, **kwargs):
|
|||||||
stdout, stderr = subproc.communicate()
|
stdout, stderr = subproc.communicate()
|
||||||
except OSError as exc:
|
except OSError as exc:
|
||||||
ret = -1
|
ret = -1
|
||||||
stderr = six.text_type(exc)
|
stderr = str(exc)
|
||||||
stdout = ""
|
stdout = ""
|
||||||
else:
|
else:
|
||||||
ret = subproc.returncode
|
ret = subproc.returncode
|
||||||
|
@ -16,7 +16,6 @@ import ast
|
|||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import six
|
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
import yaml
|
import yaml
|
||||||
@ -88,7 +87,7 @@ def main(argv=sys.argv):
|
|||||||
value = c.get('env_file', None)
|
value = c.get('env_file', None)
|
||||||
if isinstance(value, list):
|
if isinstance(value, list):
|
||||||
compose_env_files.extend(value)
|
compose_env_files.extend(value)
|
||||||
elif isinstance(value, six.string_types):
|
elif isinstance(value, str):
|
||||||
compose_env_files.extend([value])
|
compose_env_files.extend([value])
|
||||||
|
|
||||||
input_env_files = {}
|
input_env_files = {}
|
||||||
|
@ -12,11 +12,11 @@
|
|||||||
# 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 io
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import six
|
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
|
|
||||||
@ -81,13 +81,13 @@ def configure_logging():
|
|||||||
handler.setFormatter(formatter)
|
handler.setFormatter(formatter)
|
||||||
log.addHandler(handler)
|
log.addHandler(handler)
|
||||||
|
|
||||||
deploy_stdout = six.StringIO()
|
deploy_stdout = io.StringIO()
|
||||||
handler = logging.StreamHandler(deploy_stdout)
|
handler = logging.StreamHandler(deploy_stdout)
|
||||||
handler.setFormatter(formatter)
|
handler.setFormatter(formatter)
|
||||||
handler.setLevel('DEBUG')
|
handler.setLevel('DEBUG')
|
||||||
log.addHandler(handler)
|
log.addHandler(handler)
|
||||||
|
|
||||||
deploy_stderr = six.StringIO()
|
deploy_stderr = io.StringIO()
|
||||||
handler = logging.StreamHandler(deploy_stderr)
|
handler = logging.StreamHandler(deploy_stderr)
|
||||||
handler.setFormatter(formatter)
|
handler.setFormatter(formatter)
|
||||||
handler.setLevel('WARN')
|
handler.setLevel('WARN')
|
||||||
@ -149,7 +149,7 @@ def wait_required_containers(client, log,
|
|||||||
waiting_for = dict((v, re.compile(v)) for v in patterns)
|
waiting_for = dict((v, re.compile(v)) for v in patterns)
|
||||||
while waiting_for:
|
while waiting_for:
|
||||||
for name in containers_names(client.containers()):
|
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):
|
if v.match(name):
|
||||||
log.info('Pattern %s matches: %s' % (k, name))
|
log.info('Pattern %s matches: %s' % (k, name))
|
||||||
del(waiting_for[k])
|
del(waiting_for[k])
|
||||||
|
@ -20,7 +20,6 @@ import stat
|
|||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
import six
|
|
||||||
import yaml
|
import yaml
|
||||||
|
|
||||||
# legacy groups that have never had a hook script
|
# legacy groups that have never had a hook script
|
||||||
@ -109,7 +108,7 @@ def invoke_hook(c, log):
|
|||||||
hot_inputs = c.get('inputs', [])
|
hot_inputs = c.get('inputs', [])
|
||||||
for hot_input in hot_inputs:
|
for hot_input in hot_inputs:
|
||||||
if hot_input.get('type', None) == 'String' and \
|
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'])
|
hot_input['value'] = str(hot_input['value'])
|
||||||
iv = dict((i['name'], i['value']) for i in c['inputs'])
|
iv = dict((i['name'], i['value']) for i in c['inputs'])
|
||||||
# The group property indicates whether it is softwarecomponent or
|
# The group property indicates whether it is softwarecomponent or
|
||||||
|
@ -15,7 +15,6 @@ import copy
|
|||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
import six
|
|
||||||
import tempfile
|
import tempfile
|
||||||
|
|
||||||
import fixtures
|
import fixtures
|
||||||
@ -238,7 +237,7 @@ class HeatConfigTest(common.RunScriptTest):
|
|||||||
notify_data = self.json_from_file(notify_file)
|
notify_data = self.json_from_file(notify_file)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
self.outputs[hook]['deploy_status_code'],
|
self.outputs[hook]['deploy_status_code'],
|
||||||
six.text_type(notify_data['deploy_status_code']))
|
str(notify_data['deploy_status_code']))
|
||||||
self.assertIn(
|
self.assertIn(
|
||||||
self.outputs[hook]['deploy_stderr'],
|
self.outputs[hook]['deploy_stderr'],
|
||||||
notify_data['deploy_stderr'])
|
notify_data['deploy_stderr'])
|
||||||
|
@ -12,11 +12,11 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import copy
|
import copy
|
||||||
|
import io
|
||||||
import json
|
import json
|
||||||
import tempfile
|
import tempfile
|
||||||
|
|
||||||
import fixtures
|
import fixtures
|
||||||
import six
|
|
||||||
from unittest import mock
|
from unittest import mock
|
||||||
|
|
||||||
from tests import common
|
from tests import common
|
||||||
@ -80,7 +80,7 @@ class HeatConfigNotifyTest(common.RunScriptTest):
|
|||||||
super(HeatConfigNotifyTest, self).setUp()
|
super(HeatConfigNotifyTest, self).setUp()
|
||||||
self.deployed_dir = self.useFixture(fixtures.TempDir())
|
self.deployed_dir = self.useFixture(fixtures.TempDir())
|
||||||
hcn.init_logging = mock.MagicMock()
|
hcn.init_logging = mock.MagicMock()
|
||||||
self.stdin = six.StringIO()
|
self.stdin = io.StringIO()
|
||||||
|
|
||||||
def write_config_file(self, data):
|
def write_config_file(self, data):
|
||||||
config_file = tempfile.NamedTemporaryFile(mode='w')
|
config_file = tempfile.NamedTemporaryFile(mode='w')
|
||||||
|
@ -13,9 +13,9 @@
|
|||||||
|
|
||||||
import copy
|
import copy
|
||||||
import importlib
|
import importlib
|
||||||
|
import io
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
import six
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from multiprocessing import Lock
|
from multiprocessing import Lock
|
||||||
@ -69,8 +69,8 @@ class HookChefTest(common.RunScriptTest):
|
|||||||
__file__,
|
__file__,
|
||||||
'..',
|
'..',
|
||||||
'heat-config-chef/install.d/hook-chef.py')
|
'heat-config-chef/install.d/hook-chef.py')
|
||||||
sys.stdin = six.StringIO()
|
sys.stdin = io.StringIO()
|
||||||
sys.stdout = six.StringIO()
|
sys.stdout = io.StringIO()
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
super(HookChefTest, self).tearDown()
|
super(HookChefTest, self).tearDown()
|
||||||
|
Loading…
Reference in New Issue
Block a user