Remove six usage

Change-Id: Ia6b08e81f8df43e67bed0fbd082d7d7edd178fbc
This commit is contained in:
zhurong 2020-04-16 04:34:44 -07:00
parent b908aa8a87
commit 84f5778fc5
10 changed files with 14 additions and 23 deletions

View File

@ -69,7 +69,6 @@ requestsexceptions==1.4.0
rfc3986==1.1.0
Routes==2.4.1
semantic-version==2.6.0
six==1.11.0
smmap2==2.0.3
snowballstemmer==1.2.1
Sphinx==1.6.5

View File

@ -15,8 +15,6 @@
import sys
import six
from muranoagent import bunch
from muranoagent import files_manager as fm
from muranoagent import script_runner
@ -35,7 +33,7 @@ class ExecutionPlanRunner(object):
"args": bunch.Bunch(self._execution_plan.get('Parameters') or {})
}
script_globals.update(self._script_funcs)
six.exec_(self._main_script, script_globals)
exec(self._main_script, script_globals)
if '__execution_plan_exception' in script_globals:
raise script_globals['__execution_plan_exception']
return script_globals['__execution_plan_result']
@ -43,7 +41,7 @@ class ExecutionPlanRunner(object):
@staticmethod
def _unindent(script, initial_indent):
lines = script.expandtabs(4).split('\n')
min_indent = six.MAXSIZE
min_indent = sys.maxsize
for line in lines:
indent = -1
for i, c in enumerate(line):

View File

@ -13,8 +13,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import six
from oslo_utils import timeutils
from oslo_utils import uuidutils
@ -48,7 +46,7 @@ class ExecutionResult(object):
if isinstance(error, int):
error_code = error
elif isinstance(error, Exception):
message = six.text_type(error)
message = str(error)
if isinstance(error, exc.AgentException):
error_code = error.error_code
additional_info = error.additional_data

View File

@ -18,7 +18,6 @@ import os
import subprocess
from oslo_log import log as logging
import six
from muranoagent import bunch
import muranoagent.exceptions
@ -74,7 +73,7 @@ class ChefPuppetExecutorBase(object):
retcode = process.poll()
if stdout is not None:
if not isinstance(stdout, six.text_type):
if not isinstance(stdout, str):
stdout = stdout.decode('utf-8')
LOG.debug(u"'{0}' execution stdout: "
u"'{1}'".format(self.module_name, stdout))

View File

@ -23,7 +23,7 @@ import subprocess
from oslo_log import log as logging
from oslo_utils import encodeutils
from six.moves import urllib
import urllib
from muranoagent.common import config

View File

@ -46,7 +46,7 @@ class TestChefExecutor(base.MuranoAgentTestCase, fixtures.TestWithFixtures):
self.assertEqual(json.loads(node), self.get_node_atts())
@mock.patch('subprocess.Popen')
@mock.patch('six.moves.builtins.open')
@mock.patch('builtins.open')
@mock.patch('os.path.exists')
@mock.patch('os.path.isdir')
def test_cookbook(self, mock_isdir, mock_exist, open_mock,
@ -69,7 +69,7 @@ class TestChefExecutor(base.MuranoAgentTestCase, fixtures.TestWithFixtures):
self.chef_executor.run('test')
@mock.patch('subprocess.Popen')
@mock.patch('six.moves.builtins.open')
@mock.patch('builtins.open')
@mock.patch('os.path.exists')
@mock.patch('os.path.isdir')
def test_cookbook_error(self, mock_isdir, mock_exist, open_mock,

View File

@ -44,7 +44,7 @@ class TestPuppetExecutor(base.MuranoAgentTestCase, fixtures.TestWithFixtures):
node = self.puppet_executor._create_hiera_data('cookbook', atts)
self.assertEqual(node, self.get_hieradata())
@mock.patch('six.moves.builtins.open')
@mock.patch('builtins.open')
def test_generate_files(self, open_mock):
self._open_mock(open_mock)
atts = {
@ -54,13 +54,13 @@ class TestPuppetExecutor(base.MuranoAgentTestCase, fixtures.TestWithFixtures):
self.puppet_executor._generate_files('cookbook', 'recipe', atts)
@mock.patch('six.moves.builtins.open')
@mock.patch('builtins.open')
def test_configure_puppet(self, open_mock):
self._open_mock(open_mock)
self.puppet_executor._configure_puppet()
@mock.patch('subprocess.Popen')
@mock.patch('six.moves.builtins.open')
@mock.patch('builtins.open')
def test_module(self, open_mock, mock_subproc_popen):
#
# setup
@ -80,7 +80,7 @@ class TestPuppetExecutor(base.MuranoAgentTestCase, fixtures.TestWithFixtures):
self.puppet_executor.run('test')
@mock.patch('subprocess.Popen')
@mock.patch('six.moves.builtins.open')
@mock.patch('builtins.open')
def test_module_error(self, open_mock, mock_subproc_popen):
#
# setup

View File

@ -69,7 +69,7 @@ class TestFileManager(base.MuranoAgentTestCase):
@mock.patch('os.path.isdir')
@mock.patch('os.mkdir')
@mock.patch('os.makedirs')
@mock.patch('six.moves.builtins.open')
@mock.patch('builtins.open')
@mock.patch('requests.get')
def test_execution_plan_type_downloable(self, mock_requests, open_mock,
mock_makedir,
@ -136,7 +136,7 @@ class TestFileManager(base.MuranoAgentTestCase):
for file in template.get('Files'):
files.put_file(file, 'deploy')
@mock.patch('six.moves.builtins.open')
@mock.patch('builtins.open')
@mock.patch('os.path.lexists')
@mock.patch('os.path.isdir')
@mock.patch('os.makedirs')

View File

@ -14,7 +14,6 @@
# limitations under the License.
import semantic_version
import six
from muranoagent import exceptions as exc
@ -54,8 +53,7 @@ def validate_plan(plan):
def _validate_script(name, script, plan_format_version, plan):
for attr in ('Type', 'EntryPoint'):
if attr not in script or not isinstance(script[attr],
six.string_types):
if attr not in script or not isinstance(script[attr], str):
raise exc.IncorrectFormat(
2, 'Incorrect {0} entry in script {1}'.format(
attr, name))

View File

@ -11,7 +11,6 @@ oslo.log>=3.37.0 # Apache-2.0
oslo.service>=1.30.0 # Apache-2.0
oslo.utils>=3.36.0 # Apache-2.0
PyYAML>=3.12 # MIT
six>=1.11.0 # MIT
semantic-version>=2.6.0 # BSD
requests>=2.18.4 # Apache-2.0
cryptography>=2.1.4 # BSD/Apache-2.0