Remove usage of six
Remove six-library Replace the following items with Python 3 style code. - six.StringIO Change-Id: Ia8a28940edc9ca1b26ca0ef5112a44fe5fc6258d
This commit is contained in:
parent
8ff9746a30
commit
0fa2069510
@ -14,6 +14,7 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
|
||||||
|
import io
|
||||||
import select
|
import select
|
||||||
import socket
|
import socket
|
||||||
import time
|
import time
|
||||||
@ -67,7 +68,7 @@ class Client(object):
|
|||||||
self.password = password
|
self.password = password
|
||||||
if isinstance(pkey, six.string_types):
|
if isinstance(pkey, six.string_types):
|
||||||
pkey = paramiko.RSAKey.from_private_key(
|
pkey = paramiko.RSAKey.from_private_key(
|
||||||
six.StringIO(str(pkey)))
|
io.StringIO(str(pkey)))
|
||||||
self.pkey = pkey
|
self.pkey = pkey
|
||||||
self.look_for_keys = look_for_keys
|
self.look_for_keys = look_for_keys
|
||||||
self.key_filename = key_filename
|
self.key_filename = key_filename
|
||||||
|
@ -12,15 +12,12 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
from io import StringIO
|
||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
import subprocess
|
import subprocess
|
||||||
import tempfile
|
import tempfile
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
try:
|
|
||||||
from StringIO import StringIO
|
|
||||||
except ImportError:
|
|
||||||
from io import StringIO
|
|
||||||
|
|
||||||
from tempest.cmd import workspace
|
from tempest.cmd import workspace
|
||||||
from tempest.lib.common.utils import data_utils
|
from tempest.lib.common.utils import data_utils
|
||||||
|
@ -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.
|
||||||
|
|
||||||
|
from io import StringIO
|
||||||
import socket
|
import socket
|
||||||
from unittest import mock
|
from unittest import mock
|
||||||
|
|
||||||
import six
|
import six
|
||||||
from six import StringIO
|
|
||||||
import testtools
|
import testtools
|
||||||
|
|
||||||
from tempest.lib.common import ssh
|
from tempest.lib.common import ssh
|
||||||
@ -30,7 +30,7 @@ class TestSshClient(base.TestCase):
|
|||||||
SELECT_POLLIN = 1
|
SELECT_POLLIN = 1
|
||||||
|
|
||||||
@mock.patch('paramiko.RSAKey.from_private_key')
|
@mock.patch('paramiko.RSAKey.from_private_key')
|
||||||
@mock.patch('six.StringIO')
|
@mock.patch('io.StringIO')
|
||||||
def test_pkey_calls_paramiko_RSAKey(self, cs_mock, rsa_mock):
|
def test_pkey_calls_paramiko_RSAKey(self, cs_mock, rsa_mock):
|
||||||
cs_mock.return_value = mock.sentinel.csio
|
cs_mock.return_value = mock.sentinel.csio
|
||||||
pkey = 'mykey'
|
pkey = 'mykey'
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
import gzip
|
import gzip
|
||||||
|
import io
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
@ -69,7 +70,7 @@ def process_files(file_specs, url_specs, allow_lists):
|
|||||||
req = urlreq.Request(url)
|
req = urlreq.Request(url)
|
||||||
req.add_header('Accept-Encoding', 'gzip')
|
req.add_header('Accept-Encoding', 'gzip')
|
||||||
page = urlreq.urlopen(req)
|
page = urlreq.urlopen(req)
|
||||||
buf = six.StringIO(page.read())
|
buf = io.StringIO(page.read())
|
||||||
f = gzip.GzipFile(fileobj=buf)
|
f = gzip.GzipFile(fileobj=buf)
|
||||||
if scan_content(f.read().splitlines(), regexp, allow_list):
|
if scan_content(f.read().splitlines(), regexp, allow_list):
|
||||||
logs_with_errors.append(name)
|
logs_with_errors.append(name)
|
||||||
|
Loading…
Reference in New Issue
Block a user