Browse Source

Remove usage of six

Remove six-library Replace the following items with Python 3 style code.
- six.StringIO

Change-Id: Ia8a28940edc9ca1b26ca0ef5112a44fe5fc6258d
changes/49/769249/3
songwenping 3 months ago
committed by Wenping Song
parent
commit
0fa2069510
4 changed files with 7 additions and 8 deletions
  1. +2
    -1
      tempest/lib/common/ssh.py
  2. +1
    -4
      tempest/tests/cmd/test_workspace.py
  3. +2
    -2
      tempest/tests/lib/test_ssh.py
  4. +2
    -1
      tools/check_logs.py

+ 2
- 1
tempest/lib/common/ssh.py View File

@ -14,6 +14,7 @@
# under the License.
import io
import select
import socket
import time
@ -67,7 +68,7 @@ class Client(object):
self.password = password
if isinstance(pkey, six.string_types):
pkey = paramiko.RSAKey.from_private_key(
six.StringIO(str(pkey)))
io.StringIO(str(pkey)))
self.pkey = pkey
self.look_for_keys = look_for_keys
self.key_filename = key_filename


+ 1
- 4
tempest/tests/cmd/test_workspace.py View File

@ -12,15 +12,12 @@
# License for the specific language governing permissions and limitations
# under the License.
from io import StringIO
import os
import shutil
import subprocess
import tempfile
from unittest.mock import patch
try:
from StringIO import StringIO
except ImportError:
from io import StringIO
from tempest.cmd import workspace
from tempest.lib.common.utils import data_utils


+ 2
- 2
tempest/tests/lib/test_ssh.py View File

@ -12,11 +12,11 @@
# License for the specific language governing permissions and limitations
# under the License.
from io import StringIO
import socket
from unittest import mock
import six
from six import StringIO
import testtools
from tempest.lib.common import ssh
@ -30,7 +30,7 @@ class TestSshClient(base.TestCase):
SELECT_POLLIN = 1
@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):
cs_mock.return_value = mock.sentinel.csio
pkey = 'mykey'


+ 2
- 1
tools/check_logs.py View File

@ -17,6 +17,7 @@
import argparse
import gzip
import io
import os
import re
import sys
@ -69,7 +70,7 @@ def process_files(file_specs, url_specs, allow_lists):
req = urlreq.Request(url)
req.add_header('Accept-Encoding', 'gzip')
page = urlreq.urlopen(req)
buf = six.StringIO(page.read())
buf = io.StringIO(page.read())
f = gzip.GzipFile(fileobj=buf)
if scan_content(f.read().splitlines(), regexp, allow_list):
logs_with_errors.append(name)


Loading…
Cancel
Save