Remove six
Replace to Python 3 style code. Change-Id: Ieaeb7b0dc4dceb519778ec8d7e45f53a070d34e2
This commit is contained in:
parent
82909f4824
commit
a9011e5558
@ -17,11 +17,9 @@
|
||||
import abc
|
||||
|
||||
from os_brick import executor
|
||||
import six
|
||||
|
||||
|
||||
@six.add_metaclass(abc.ABCMeta)
|
||||
class VolumeEncryptor(executor.Executor):
|
||||
class VolumeEncryptor(executor.Executor, metaclass=abc.ABCMeta):
|
||||
"""Base class to support encrypted volumes.
|
||||
|
||||
A VolumeEncryptor provides hooks for attaching and detaching volumes, which
|
||||
|
@ -15,7 +15,6 @@
|
||||
"""Exceptions for the Brick library."""
|
||||
|
||||
from oslo_concurrency import processutils as putils
|
||||
import six
|
||||
import traceback
|
||||
|
||||
from os_brick.i18n import _
|
||||
@ -67,9 +66,6 @@ class BrickException(Exception):
|
||||
self.msg = message
|
||||
super(BrickException, self).__init__(message)
|
||||
|
||||
def __unicode__(self):
|
||||
return six.text_type(self.msg)
|
||||
|
||||
|
||||
class NotFound(BrickException):
|
||||
message = _("Resource could not be found.")
|
||||
@ -200,7 +196,7 @@ class ExceptionChainer(BrickException):
|
||||
for i, t in enumerate(tracebacks))
|
||||
return self._repr
|
||||
|
||||
__str__ = __unicode__ = __repr__
|
||||
__str__ = __repr__
|
||||
|
||||
def __nonzero__(self):
|
||||
# We want to be able to do boolean checks on the exception
|
||||
|
@ -17,7 +17,6 @@ import os
|
||||
from oslo_concurrency import lockutils
|
||||
from oslo_log import log as logging
|
||||
from oslo_service import loopingcall
|
||||
import six
|
||||
|
||||
from os_brick import exception
|
||||
from os_brick.i18n import _
|
||||
@ -80,7 +79,7 @@ class FibreChannelConnector(base.BaseLinuxConnector):
|
||||
wwns = target_wwns
|
||||
elif isinstance(target_wwn, list):
|
||||
wwns = target_wwn
|
||||
elif isinstance(target_wwn, six.string_types):
|
||||
elif isinstance(target_wwn, str):
|
||||
wwns = [target_wwn]
|
||||
else:
|
||||
wwns = []
|
||||
|
@ -15,8 +15,7 @@
|
||||
import json
|
||||
import os
|
||||
import requests
|
||||
import six
|
||||
from six.moves import urllib
|
||||
import urllib
|
||||
|
||||
from oslo_concurrency import lockutils
|
||||
from oslo_log import log as logging
|
||||
@ -537,7 +536,7 @@ class ScaleIOConnector(base.BaseLinuxConnector):
|
||||
(out, _err) = self._execute('blockdev', '--getsize64',
|
||||
device, run_as_root=True,
|
||||
root_helper=self._root_helper)
|
||||
var = six.text_type(out.strip())
|
||||
var = str(out.strip())
|
||||
LOG.debug("Device %(dev)s size: %(var)s",
|
||||
{'dev': device, 'var': var})
|
||||
if var.isnumeric():
|
||||
|
@ -16,8 +16,6 @@
|
||||
import os
|
||||
import time
|
||||
|
||||
import six
|
||||
|
||||
from oslo_log import log as logging
|
||||
from oslo_utils import importutils
|
||||
|
||||
@ -191,7 +189,7 @@ class StorPoolConnector(base.BaseLinuxConnector):
|
||||
(out, _err) = self._execute('blockdev', '--getsize64',
|
||||
device, run_as_root=True,
|
||||
root_helper=self._root_helper)
|
||||
var = six.text_type(out).strip()
|
||||
var = str(out).strip()
|
||||
if var.isnumeric():
|
||||
return int(var)
|
||||
else:
|
||||
|
@ -27,7 +27,6 @@ try:
|
||||
from oslo_vmware import vim_util
|
||||
except ImportError:
|
||||
vim_util = None
|
||||
import six
|
||||
|
||||
from os_brick import exception
|
||||
from os_brick.i18n import _
|
||||
@ -257,7 +256,7 @@ class VmdkConnector(initiator_connector.InitiatorConnector):
|
||||
VmdkConnector.TMP_IMAGES_DATASTORE_FOLDER_PATH,
|
||||
os.path.basename(tmp_file_path))
|
||||
self._create_temp_ds_folder(
|
||||
session, six.text_type(ds_path.parent), dc_ref)
|
||||
session, str(ds_path.parent), dc_ref)
|
||||
|
||||
with open(tmp_file_path, "rb") as tmp_file:
|
||||
dc_name = session.invoke_api(
|
||||
@ -272,7 +271,7 @@ class VmdkConnector(initiator_connector.InitiatorConnector):
|
||||
disk_device = self._get_disk_device(session, backing)
|
||||
self._detach_disk_from_backing(session, backing, disk_device)
|
||||
|
||||
src = six.text_type(ds_path)
|
||||
src = str(ds_path)
|
||||
LOG.debug("Copying %(src)s to %(dest)s", {'src': src,
|
||||
'dest': vmdk_path})
|
||||
disk_mgr = session.vim.service_content.virtualDiskManager
|
||||
|
@ -15,15 +15,12 @@
|
||||
|
||||
import abc
|
||||
|
||||
import six
|
||||
|
||||
from os_brick import exception
|
||||
from os_brick import executor
|
||||
from os_brick import initiator
|
||||
|
||||
|
||||
@six.add_metaclass(abc.ABCMeta)
|
||||
class InitiatorConnector(executor.Executor):
|
||||
class InitiatorConnector(executor.Executor, metaclass=abc.ABCMeta):
|
||||
|
||||
# This object can be used on any platform (x86, S390)
|
||||
platform = initiator.PLATFORM_ALL
|
||||
|
@ -23,7 +23,6 @@ import time
|
||||
|
||||
from oslo_concurrency import processutils as putils
|
||||
from oslo_log import log as logging
|
||||
import six
|
||||
|
||||
from os_brick import exception
|
||||
from os_brick import executor
|
||||
@ -539,7 +538,7 @@ class LinuxSCSI(executor.Executor):
|
||||
(out, _err) = self._execute('blockdev', '--getsize64',
|
||||
device, run_as_root=True,
|
||||
root_helper=self._root_helper)
|
||||
var = six.text_type(out.strip())
|
||||
var = str(out.strip())
|
||||
if var.isnumeric():
|
||||
return int(var)
|
||||
else:
|
||||
|
@ -26,8 +26,6 @@ from os_brick import utils
|
||||
from oslo_concurrency import processutils as putils
|
||||
from oslo_log import log as logging
|
||||
from oslo_utils import excutils
|
||||
from six import moves
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
@ -313,7 +311,7 @@ class LVM(executor.Executor):
|
||||
lv_list = []
|
||||
if out is not None:
|
||||
volumes = out.split()
|
||||
iterator = moves.zip(*[iter(volumes)] * 3) # pylint: disable=E1101
|
||||
iterator = zip(*[iter(volumes)] * 3) # pylint: disable=E1101
|
||||
for vg, name, size in iterator:
|
||||
lv_list.append({"vg": vg, "name": name, "size": size})
|
||||
|
||||
|
@ -38,7 +38,6 @@ the urgency of (1)), then work on the larger refactor that addresses
|
||||
|
||||
import os
|
||||
import signal
|
||||
import six
|
||||
import threading
|
||||
import time
|
||||
|
||||
@ -188,7 +187,7 @@ def execute(*cmd, **kwargs):
|
||||
|
||||
sanitized_cmd = strutils.mask_password(' '.join(cmd))
|
||||
raise putils.ProcessExecutionError(
|
||||
cmd=sanitized_cmd, description=six.text_type(e))
|
||||
cmd=sanitized_cmd, description=str(e))
|
||||
|
||||
|
||||
# See comment on `execute`
|
||||
|
@ -22,7 +22,6 @@ import tempfile
|
||||
from oslo_concurrency import processutils
|
||||
from oslo_log import log as logging
|
||||
from oslo_utils.secretutils import md5
|
||||
import six
|
||||
|
||||
from os_brick import exception
|
||||
from os_brick import executor
|
||||
@ -68,7 +67,7 @@ class RemoteFsClient(executor.Executor):
|
||||
|
||||
def _get_hash_str(self, base_str):
|
||||
"""Return a string that represents hash of base_str (hex format)."""
|
||||
if isinstance(base_str, six.text_type):
|
||||
if isinstance(base_str, str):
|
||||
base_str = base_str.encode('utf-8')
|
||||
return md5(base_str,
|
||||
usedforsecurity=False).hexdigest()
|
||||
@ -152,7 +151,7 @@ class RemoteFsClient(executor.Executor):
|
||||
{'sh': nfs_share, 'mnt_type': mnt_type})
|
||||
return
|
||||
except Exception as e:
|
||||
mnt_errors[mnt_type] = six.text_type(e)
|
||||
mnt_errors[mnt_type] = str(e)
|
||||
LOG.debug('Failed to do %s mount.', mnt_type)
|
||||
raise exception.BrickException(_("NFS mount failed for share %(sh)s. "
|
||||
"Error - %(error)s")
|
||||
|
@ -18,8 +18,6 @@ import binascii
|
||||
import copy
|
||||
from unittest import mock
|
||||
|
||||
import six
|
||||
|
||||
from castellan.common.objects import symmetric_key as key
|
||||
from castellan.tests.unit.key_manager import fake
|
||||
from os_brick.encryptors import cryptsetup
|
||||
@ -113,7 +111,7 @@ class CryptsetupEncryptorTestCase(test_base.VolumeEncryptorTestCase):
|
||||
root_helper=self.root_helper,
|
||||
connection_info=connection_info,
|
||||
keymgr=fake.fake_api())
|
||||
self.assertIn(type, six.text_type(exc))
|
||||
self.assertIn(type, str(exc))
|
||||
|
||||
@mock.patch('os_brick.executor.Executor._execute')
|
||||
@mock.patch('os.path.exists', return_value=True)
|
||||
|
@ -16,7 +16,6 @@ import os
|
||||
from unittest import mock
|
||||
|
||||
import ddt
|
||||
import six
|
||||
|
||||
from os_brick import exception
|
||||
from os_brick.initiator.connectors import base
|
||||
@ -259,7 +258,7 @@ class FibreChannelConnectorTestCase(test_connector.ConnectorTestCase):
|
||||
# Should work for string, unicode, and list
|
||||
wwns_luns = [
|
||||
('1234567890123456', 1),
|
||||
(six.text_type('1234567890123456'), 1),
|
||||
(str('1234567890123456'), 1),
|
||||
(['1234567890123456', '1234567890123457'], 1),
|
||||
(['1234567890123456', '1234567890123457'], 1),
|
||||
]
|
||||
@ -720,7 +719,7 @@ class FibreChannelConnectorTestCase(test_connector.ConnectorTestCase):
|
||||
# Check that we turn to lowercase target wwns
|
||||
key = 'target_wwns' if 'target_wwns' in target_info else 'target_wwn'
|
||||
wwns = target_info.get(key)
|
||||
wwns = [wwns] if isinstance(wwns, six.string_types) else wwns
|
||||
wwns = [wwns] if isinstance(wwns, str) else wwns
|
||||
wwns = [w.lower() for w in wwns]
|
||||
if wwns:
|
||||
self.assertEqual(wwns, conn['data'][key])
|
||||
|
@ -16,8 +16,6 @@ import os
|
||||
import requests
|
||||
from unittest import mock
|
||||
|
||||
import six
|
||||
|
||||
from os_brick import exception
|
||||
from os_brick.initiator.connectors import scaleio
|
||||
from os_brick.tests.initiator import test_connector
|
||||
@ -110,7 +108,7 @@ class ScaleIOConnectorTestCase(test_connector.ConnectorTestCase):
|
||||
self.status_code = status_code
|
||||
|
||||
def json(self, **kwargs):
|
||||
if isinstance(self._content, six.string_types):
|
||||
if isinstance(self._content, str):
|
||||
return super(ScaleIOConnectorTestCase.MockHTTPSResponse,
|
||||
self).json(**kwargs)
|
||||
|
||||
@ -118,7 +116,7 @@ class ScaleIOConnectorTestCase(test_connector.ConnectorTestCase):
|
||||
|
||||
@property
|
||||
def text(self):
|
||||
if not isinstance(self._content, six.string_types):
|
||||
if not isinstance(self._content, str):
|
||||
return json.dumps(self._content)
|
||||
|
||||
self._content = self._content.encode('utf-8')
|
||||
|
@ -142,7 +142,7 @@ class LinuxSCSITestCase(base.TestCase):
|
||||
wwn = self.linuxscsi.get_scsi_wwn(fake_path)
|
||||
self.assertEqual(fake_wwn, wwn)
|
||||
|
||||
@mock.patch('six.moves.builtins.open')
|
||||
@mock.patch('builtins.open')
|
||||
def test_get_dm_name(self, open_mock):
|
||||
dm_map_name = '3600d0230000000000e13955cc3757800'
|
||||
cm_open = open_mock.return_value.__enter__.return_value
|
||||
@ -151,7 +151,7 @@ class LinuxSCSITestCase(base.TestCase):
|
||||
self.assertEqual(dm_map_name, res)
|
||||
open_mock.assert_called_once_with('/sys/block/dm-0/dm/name')
|
||||
|
||||
@mock.patch('six.moves.builtins.open', side_effect=IOError)
|
||||
@mock.patch('builtins.open', side_effect=IOError)
|
||||
def test_get_dm_name_failure(self, open_mock):
|
||||
self.assertEqual('', self.linuxscsi.get_dm_name('dm-0'))
|
||||
|
||||
@ -860,7 +860,7 @@ loop0 0"""
|
||||
'id': '0',
|
||||
'lun': '0'})
|
||||
|
||||
@mock.patch('six.moves.builtins.open')
|
||||
@mock.patch('builtins.open')
|
||||
def test_get_sysfs_wwn_mpath(self, open_mock):
|
||||
wwn = '3600d0230000000000e13955cc3757800'
|
||||
cm_open = open_mock.return_value.__enter__.return_value
|
||||
@ -881,7 +881,7 @@ loop0 0"""
|
||||
glob_mock.assert_called_once_with('/dev/disk/by-id/scsi-*')
|
||||
get_wwid_mock.assert_called_once_with(mock.sentinel.device_names)
|
||||
|
||||
@mock.patch('six.moves.builtins.open', side_effect=Exception)
|
||||
@mock.patch('builtins.open', side_effect=Exception)
|
||||
@mock.patch('glob.glob')
|
||||
@mock.patch.object(linuxscsi.LinuxSCSI, 'get_sysfs_wwid')
|
||||
def test_get_sysfs_wwn_mpath_exc(self, get_wwid_mock, glob_mock,
|
||||
@ -974,7 +974,7 @@ loop0 0"""
|
||||
{'wwn_type': 'eui.', 'num_val': '2'},
|
||||
{'wwn_type': 'naa.', 'num_val': '3'})
|
||||
@ddt.unpack
|
||||
@mock.patch('six.moves.builtins.open')
|
||||
@mock.patch('builtins.open')
|
||||
def test_get_sysfs_wwid(self, open_mock, wwn_type, num_val):
|
||||
read_fail = mock.MagicMock()
|
||||
read_fail.__enter__.return_value.read.side_effect = IOError
|
||||
@ -989,7 +989,7 @@ loop0 0"""
|
||||
mock.call('/sys/block/sdb/device/wwid'),
|
||||
mock.call('/sys/block/sdc/device/wwid')])
|
||||
|
||||
@mock.patch('six.moves.builtins.open', side_effect=IOError)
|
||||
@mock.patch('builtins.open', side_effect=IOError)
|
||||
def test_get_sysfs_wwid_not_found(self, open_mock):
|
||||
res = self.linuxscsi.get_sysfs_wwid(['sda', 'sdb'])
|
||||
self.assertEqual('', res)
|
||||
|
@ -13,7 +13,6 @@
|
||||
from unittest import mock
|
||||
|
||||
from oslo_concurrency import processutils as putils
|
||||
import six
|
||||
|
||||
from os_brick import exception
|
||||
from os_brick import privileged
|
||||
@ -114,7 +113,7 @@ class PrivRootwrapTestCase(base.TestCase):
|
||||
out, err = priv_rootwrap.custom_execute('sleep', '2', timeout=0.05,
|
||||
raise_timeout=False)
|
||||
self.assertEqual('', out)
|
||||
self.assertIsInstance(err, six.string_types)
|
||||
self.assertIsInstance(err, str)
|
||||
|
||||
def test_custom_execute_check_exit_code(self):
|
||||
self.assertRaises(putils.ProcessExecutionError,
|
||||
@ -125,7 +124,7 @@ class PrivRootwrapTestCase(base.TestCase):
|
||||
out, err = priv_rootwrap.custom_execute('ls', '-y',
|
||||
check_exit_code=False)
|
||||
self.assertEqual('', out)
|
||||
self.assertIsInstance(err, six.string_types)
|
||||
self.assertIsInstance(err, str)
|
||||
|
||||
@mock.patch.object(priv_rootwrap.unlink_root.privsep_entrypoint,
|
||||
'client_mode', False)
|
||||
|
@ -15,7 +15,6 @@ import tempfile
|
||||
from unittest import mock
|
||||
|
||||
from oslo_concurrency import processutils as putils
|
||||
import six
|
||||
|
||||
from os_brick import exception
|
||||
from os_brick.privileged import rootwrap as priv_rootwrap
|
||||
@ -61,13 +60,12 @@ class RemoteFsClientTestCase(base.TestCase):
|
||||
def test_read_mounts(self):
|
||||
mounts = """device1 mnt_point1 ext4 rw,seclabel,relatime 0 0
|
||||
device2 mnt_point2 ext4 rw,seclabel,relatime 0 0"""
|
||||
mockopen = mock.mock_open(read_data=mounts)
|
||||
mockopen.return_value.__iter__ = lambda self: iter(self.readline, '')
|
||||
with mock.patch.object(six.moves.builtins, "open", mockopen,
|
||||
create=True):
|
||||
with mock.patch('os_brick.remotefs.remotefs.open',
|
||||
mock.mock_open(read_data=mounts)) as mock_open:
|
||||
client = remotefs.RemoteFsClient("cifs", root_helper='true',
|
||||
smbfs_mount_point_base='/mnt')
|
||||
ret = client._read_mounts()
|
||||
mock_open.assert_called_once_with('/proc/mounts', 'r')
|
||||
self.assertEqual(ret, {'mnt_point1': 'device1',
|
||||
'mnt_point2': 'device2'})
|
||||
|
||||
@ -197,9 +195,8 @@ class VZStorageRemoteFSClientTestVase(RemoteFsClientTestCase):
|
||||
|
||||
with mock.patch.object(tempfile, 'mkdtemp',
|
||||
return_value=tmp_dir):
|
||||
mock_open = mock.mock_open()
|
||||
with mock.patch.object(six.moves.builtins, "open",
|
||||
mock_open, create=True):
|
||||
with mock.patch('os_brick.remotefs.remotefs.open',
|
||||
new_callable=mock.mock_open) as mock_open:
|
||||
client.mount(share)
|
||||
|
||||
write_calls = [mock.call(tmp_dir + 'bs_list', 'w'),
|
||||
|
@ -15,8 +15,6 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import six
|
||||
|
||||
from os_brick import exception
|
||||
from os_brick.tests import base
|
||||
|
||||
@ -27,10 +25,10 @@ class BrickExceptionTestCase(base.TestCase):
|
||||
message = "default message"
|
||||
|
||||
exc = FakeBrickException()
|
||||
self.assertEqual(six.text_type(exc), 'default message')
|
||||
self.assertEqual(str(exc), 'default message')
|
||||
|
||||
def test_error_msg(self):
|
||||
self.assertEqual(six.text_type(exception.BrickException('test')),
|
||||
self.assertEqual(str(exception.BrickException('test')),
|
||||
'test')
|
||||
|
||||
def test_default_error_msg_with_kwargs(self):
|
||||
@ -38,14 +36,14 @@ class BrickExceptionTestCase(base.TestCase):
|
||||
message = "default message: %(code)s"
|
||||
|
||||
exc = FakeBrickException(code=500)
|
||||
self.assertEqual(six.text_type(exc), 'default message: 500')
|
||||
self.assertEqual(str(exc), 'default message: 500')
|
||||
|
||||
def test_error_msg_exception_with_kwargs(self):
|
||||
class FakeBrickException(exception.BrickException):
|
||||
message = "default message: %(mispelled_code)s"
|
||||
|
||||
exc = FakeBrickException(code=500)
|
||||
self.assertEqual(six.text_type(exc),
|
||||
self.assertEqual(str(exc),
|
||||
'default message: %(mispelled_code)s')
|
||||
|
||||
def test_default_error_code(self):
|
||||
|
@ -18,8 +18,6 @@ from unittest import mock
|
||||
|
||||
from oslo_concurrency import processutils as putils
|
||||
from oslo_context import context as context_utils
|
||||
import six
|
||||
import testtools
|
||||
|
||||
from os_brick import executor as brick_executor
|
||||
from os_brick.privileged import rootwrap
|
||||
@ -63,13 +61,12 @@ class TestExecutor(base.TestCase):
|
||||
self.assertEqual(u'Espa\xf1a', stdout)
|
||||
self.assertEqual(u'Z\xfcrich', stderr)
|
||||
|
||||
@testtools.skipUnless(six.PY3, 'Specific test for Python 3')
|
||||
@mock.patch('sys.stdin', encoding='UTF-8')
|
||||
@mock.patch('os_brick.executor.priv_rootwrap.execute')
|
||||
def test_execute_non_safe_bytes_exception(self, execute_mock, stdin_mock):
|
||||
execute_mock.side_effect = putils.ProcessExecutionError(
|
||||
stdout=six.binary_type('España', 'utf-8'),
|
||||
stderr=six.binary_type('Zürich', 'utf-8'))
|
||||
stdout=bytes('España', 'utf-8'),
|
||||
stderr=bytes('Zürich', 'utf-8'))
|
||||
|
||||
executor = brick_executor.Executor(root_helper=None)
|
||||
exc = self.assertRaises(putils.ProcessExecutionError,
|
||||
@ -77,12 +74,11 @@ class TestExecutor(base.TestCase):
|
||||
self.assertEqual(u'Espa\xf1a', exc.stdout)
|
||||
self.assertEqual(u'Z\xfcrich', exc.stderr)
|
||||
|
||||
@testtools.skipUnless(six.PY3, 'Specific test for Python 3')
|
||||
@mock.patch('sys.stdin', encoding='UTF-8')
|
||||
@mock.patch('os_brick.executor.priv_rootwrap.execute')
|
||||
def test_execute_non_safe_bytes(self, execute_mock, stdin_mock):
|
||||
execute_mock.return_value = (six.binary_type('España', 'utf-8'),
|
||||
six.binary_type('Zürich', 'utf-8'))
|
||||
execute_mock.return_value = (bytes('España', 'utf-8'),
|
||||
bytes('Zürich', 'utf-8'))
|
||||
|
||||
executor = brick_executor.Executor(root_helper=None)
|
||||
stdout, stderr = executor._execute()
|
||||
|
@ -16,8 +16,6 @@
|
||||
from unittest import mock
|
||||
|
||||
import ddt
|
||||
import six
|
||||
|
||||
from os_brick import exception
|
||||
from os_brick.initiator.windows import base as base_win_conn
|
||||
from os_brick.tests.windows import fake_win_conn
|
||||
@ -87,7 +85,8 @@ class BaseWindowsConnectorTestCase(test_base.WindowsConnectorTestBase):
|
||||
mock_get_uid_and_type.assert_called_once_with(mock.sentinel.dev_num)
|
||||
|
||||
@ddt.data(None, IOError)
|
||||
@mock.patch.object(six.moves.builtins, 'open')
|
||||
@mock.patch('os_brick.initiator.windows.base.open',
|
||||
new_callable=mock.mock_open)
|
||||
def test_check_valid_device(self, exc, mock_open):
|
||||
mock_open.side_effect = exc
|
||||
|
||||
|
@ -18,9 +18,7 @@ import logging as py_logging
|
||||
import time
|
||||
|
||||
from oslo_log import log as logging
|
||||
from oslo_utils import encodeutils
|
||||
from oslo_utils import strutils
|
||||
import six
|
||||
|
||||
from os_brick.i18n import _
|
||||
|
||||
@ -40,7 +38,6 @@ def _sleep(duration):
|
||||
|
||||
time.sleep = _sleep
|
||||
|
||||
|
||||
import tenacity # noqa
|
||||
|
||||
|
||||
@ -55,7 +52,7 @@ def retry(exceptions, interval=1, retries=3, backoff_rate=2):
|
||||
|
||||
def _decorator(f):
|
||||
|
||||
@six.wraps(f)
|
||||
@functools.wraps(f)
|
||||
def _wrapper(*args, **kwargs):
|
||||
r = tenacity.Retrying(
|
||||
before_sleep=tenacity.before_sleep_log(LOG, logging.DEBUG),
|
||||
@ -150,7 +147,7 @@ def trace(f):
|
||||
# and don't use mask_dict_password because it results in
|
||||
# an infinite recursion failure.
|
||||
'all_args': strutils.mask_password(
|
||||
six.text_type(all_args))})
|
||||
str(all_args))})
|
||||
|
||||
start_time = time.time() * 1000
|
||||
try:
|
||||
@ -166,7 +163,7 @@ def trace(f):
|
||||
|
||||
if isinstance(result, dict):
|
||||
mask_result = strutils.mask_dict_password(result)
|
||||
elif isinstance(result, six.string_types):
|
||||
elif isinstance(result, str):
|
||||
mask_result = strutils.mask_password(result)
|
||||
else:
|
||||
mask_result = result
|
||||
@ -184,14 +181,9 @@ def convert_str(text):
|
||||
|
||||
Convert bytes and Unicode strings to native strings:
|
||||
|
||||
* convert to bytes on Python 2:
|
||||
encode Unicode using encodeutils.safe_encode()
|
||||
* convert to Unicode on Python 3: decode bytes from UTF-8
|
||||
"""
|
||||
if six.PY2:
|
||||
return encodeutils.to_utf8(text)
|
||||
if isinstance(text, bytes):
|
||||
return text.decode('utf-8')
|
||||
else:
|
||||
if isinstance(text, bytes):
|
||||
return text.decode('utf-8')
|
||||
else:
|
||||
return text
|
||||
return text
|
||||
|
@ -15,14 +15,13 @@
|
||||
# under the License.
|
||||
|
||||
"""pylint error checking."""
|
||||
|
||||
from io import StringIO
|
||||
import json
|
||||
import re
|
||||
import sys
|
||||
|
||||
from pylint import lint
|
||||
from pylint.reporters import text
|
||||
from six.moves import cStringIO as StringIO
|
||||
|
||||
ignore_codes = [
|
||||
# Note(maoy): E1103 is error code related to partial type inference
|
||||
|
Loading…
x
Reference in New Issue
Block a user