Merge "Remove six.byte2int/int2byte"

This commit is contained in:
Zuul 2020-11-09 16:34:22 +00:00 committed by Gerrit Code Review
commit d6689e316c
8 changed files with 14 additions and 17 deletions

View File

@ -20,8 +20,6 @@ import functools
import re import re
import unicodedata import unicodedata
import six
from nova.i18n import _ from nova.i18n import _
from nova.objects import tag from nova.objects import tag
@ -94,7 +92,7 @@ def _is_printable(char):
def _get_all_chars(): def _get_all_chars():
for i in range(0xFFFF): for i in range(0xFFFF):
yield six.unichr(i) yield chr(i)
# build a regex that matches all printable characters. This allows # build a regex that matches all printable characters. This allows

View File

@ -71,7 +71,7 @@ def validate_args(fn, *args, **kwargs):
num_defaults = len(argspec.defaults or []) num_defaults = len(argspec.defaults or [])
required_args = argspec.args[:len(argspec.args) - num_defaults] required_args = argspec.args[:len(argspec.args) - num_defaults]
if six.get_method_self(fn) is not None: if fn.__self__ is not None:
required_args.pop(0) required_args.pop(0)
missing = [arg for arg in required_args if arg not in kwargs] missing = [arg for arg in required_args if arg not in kwargs]

View File

@ -130,7 +130,7 @@ def check_instance_state(vm_state=None, task_state=(None,),
task_state = set(task_state) task_state = set(task_state)
def outer(f): def outer(f):
@six.wraps(f) @functools.wraps(f)
def inner(self, context, instance, *args, **kw): def inner(self, context, instance, *args, **kw):
if vm_state is not None and instance.vm_state not in vm_state: if vm_state is not None and instance.vm_state not in vm_state:
raise exception.InstanceInvalidState( raise exception.InstanceInvalidState(
@ -170,7 +170,7 @@ def reject_instance_state(vm_state=None, task_state=None):
task_state = _set_or_none(task_state) task_state = _set_or_none(task_state)
def outer(f): def outer(f):
@six.wraps(f) @functools.wraps(f)
def inner(self, context, instance, *args, **kw): def inner(self, context, instance, *args, **kw):
_InstanceInvalidState = functools.partial( _InstanceInvalidState = functools.partial(
exception.InstanceInvalidState, exception.InstanceInvalidState,
@ -202,7 +202,7 @@ def check_instance_host(check_is_up=False):
compute service status is not UP or MAINTENANCE compute service status is not UP or MAINTENANCE
""" """
def outer(function): def outer(function):
@six.wraps(function) @functools.wraps(function)
def wrapped(self, context, instance, *args, **kwargs): def wrapped(self, context, instance, *args, **kwargs):
if not instance.host: if not instance.host:
raise exception.InstanceNotReady(instance_id=instance.uuid) raise exception.InstanceNotReady(instance_id=instance.uuid)
@ -221,7 +221,7 @@ def check_instance_host(check_is_up=False):
def check_instance_lock(function): def check_instance_lock(function):
@six.wraps(function) @functools.wraps(function)
def inner(self, context, instance, *args, **kwargs): def inner(self, context, instance, *args, **kwargs):
if instance.locked and not context.is_admin: if instance.locked and not context.is_admin:
raise exception.InstanceIsLocked(instance_uuid=instance.uuid) raise exception.InstanceIsLocked(instance_uuid=instance.uuid)

View File

@ -6663,7 +6663,7 @@ class ComputeManager(manager.Manager):
output = self.driver.get_console_output(context, instance) output = self.driver.get_console_output(context, instance)
if type(output) is six.text_type: if type(output) is six.text_type:
output = six.b(output) output = output.encode("latin-1")
if tail_length is not None: if tail_length is not None:
output = self._tail_log(output, tail_length) output = self._tail_log(output, tail_length)

View File

@ -123,7 +123,7 @@ class RFBSecurityProxy(base.SecurityProxy):
raise exception.SecurityProxyNegotiationFailed(reason=reason) raise exception.SecurityProxyNegotiationFailed(reason=reason)
# Negotiate security with server # Negotiate security with server
permitted_auth_types_cnt = six.byte2int(recv(compute_sock, 1)) permitted_auth_types_cnt = recv(compute_sock, 1)[0]
if permitted_auth_types_cnt == 0: if permitted_auth_types_cnt == 0:
# Decode the reason why the request failed # Decode the reason why the request failed
@ -148,8 +148,8 @@ class RFBSecurityProxy(base.SecurityProxy):
# Negotiate security with client before we say "ok" to the server # Negotiate security with client before we say "ok" to the server
# send 1:[None] # send 1:[None]
tenant_sock.sendall(auth.AUTH_STATUS_PASS + tenant_sock.sendall(auth.AUTH_STATUS_PASS +
six.int2byte(auth.AuthType.NONE)) bytes((auth.AuthType.NONE,)))
client_auth = six.byte2int(recv(tenant_sock, 1)) client_auth = recv(tenant_sock, 1)[0]
if client_auth != auth.AuthType.NONE: if client_auth != auth.AuthType.NONE:
self._fail(tenant_sock, compute_sock, self._fail(tenant_sock, compute_sock,
@ -172,7 +172,7 @@ class RFBSecurityProxy(base.SecurityProxy):
raise exception.SecurityProxyNegotiationFailed( raise exception.SecurityProxyNegotiationFailed(
reason=_("No compute auth available: %s") % six.text_type(e)) reason=_("No compute auth available: %s") % six.text_type(e))
compute_sock.sendall(six.int2byte(scheme.security_type())) compute_sock.sendall(bytes((scheme.security_type(),)))
LOG.debug("Using security type %d with server, None with client", LOG.debug("Using security type %d with server, None with client",
scheme.security_type()) scheme.security_type())

View File

@ -18,7 +18,6 @@ import time
from oslo_utils import fixture as utils_fixture from oslo_utils import fixture as utils_fixture
from oslo_utils import timeutils from oslo_utils import timeutils
import six
from nova.api.openstack import api_version_request as avr from nova.api.openstack import api_version_request as avr
import nova.conf import nova.conf
@ -33,7 +32,7 @@ class ServersSampleBase(api_sample_base.ApiSampleTestBaseV21):
microversion = None microversion = None
sample_dir = 'servers' sample_dir = 'servers'
user_data_contents = six.b('#!/bin/bash\n/bin/su\necho "I am in you!"\n') user_data_contents = b'#!/bin/bash\n/bin/su\necho "I am in you!"\n'
user_data = base64.b64encode(user_data_contents) user_data = base64.b64encode(user_data_contents)
common_req_names = [ common_req_names = [

View File

@ -80,7 +80,7 @@ class ValidationRegex(test.NoDBTestCase):
# about. The algorithm works for all ranges. # about. The algorithm works for all ranges.
def _get_all_chars(): def _get_all_chars():
for i in range(0x7F): for i in range(0x7F):
yield six.unichr(i) yield chr(i)
self.useFixture(fixtures.MonkeyPatch( self.useFixture(fixtures.MonkeyPatch(
'nova.api.validation.parameter_types._get_all_chars', 'nova.api.validation.parameter_types._get_all_chars',

View File

@ -585,7 +585,7 @@ class ValidateIntegerTestCase(test.NoDBTestCase):
max_value=54) max_value=54)
self.assertRaises(exception.InvalidInput, self.assertRaises(exception.InvalidInput,
utils.validate_integer, utils.validate_integer,
six.unichr(129), "UnicodeError", chr(129), "UnicodeError",
max_value=1000) max_value=1000)