Remove six.PY3

The Python 2.7 Support has been dropped since Ussuri.
So remove hacking rules for compatibility between python 2 and 3.

Change-Id: Id3fd78b5d3e21579975ea0d0fc65e4f66ea4582e
This commit is contained in:
likui 2020-09-03 16:05:38 +08:00
parent efc9bae2b9
commit 5bf159de36
7 changed files with 8 additions and 28 deletions

View File

@ -70,10 +70,7 @@ def add_support_for_localization():
if os.path.exists(os.path.join(possible_topdir, 'nova', '__init__.py')):
sys.path.insert(0, possible_topdir)
if six.PY3:
gettext.install('nova')
else:
gettext.install('nova', unicode=True)
gettext.install('nova')
MAIN_RUNNER = None

View File

@ -59,14 +59,10 @@ import heapq
import logging
import os
import unittest
import six
import sys
import time
if six.PY3:
gettext.install('nova')
else:
gettext.install('nova', unicode=True)
gettext.install('nova')
from nose import config
from nose import core

View File

@ -25,7 +25,6 @@ import traceback
import eventlet
from oslo_log import log as logging
import proboscis
import six
from six.moves import urllib
import wsgi_intercept
from wsgi_intercept.httplib2_intercept import install as wsgi_install
@ -57,10 +56,7 @@ def add_support_for_localization():
if os.path.exists(os.path.join(possible_topdir, 'nova', '__init__.py')):
sys.path.insert(0, possible_topdir)
if six.PY3:
gettext.install('nova')
else:
gettext.install('nova', unicode=True)
gettext.install('nova')
def initialize_trove(config_file):

View File

@ -25,7 +25,6 @@ from keystoneauth1 import loading
from keystoneauth1 import session
from oslo_log import log as logging
from oslo_utils import encodeutils
import six
from trove.common import cfg
from trove.common import exception
@ -110,8 +109,7 @@ class DesignateInstanceEntryFactory(driver.DnsInstanceEntryFactory):
name = encodeutils.to_utf8(instance_id)
name = hashlib.md5(name).digest()
name = base64.b32encode(name)[:11].lower()
if six.PY3:
name = name.decode('ascii')
name = name.decode('ascii')
hostname = ("%s.%s" % (name, zone.name))
# Removing the leading dot if present
if hostname.endswith('.'):

View File

@ -108,10 +108,7 @@ class FakeSwiftConnection(object):
object_checksum = md5(self.container_objects[object_name])
# The manifest file etag for a HEAD or GET is the checksum of
# the concatenated checksums.
if six.PY3:
checksum.update(object_checksum.hexdigest().encode())
else:
checksum.update(object_checksum.hexdigest())
checksum.update(object_checksum.hexdigest().encode())
# this is included to test bad swift segment etags
if name.startswith("bad_manifest_etag_"):
return {'etag': '"this_is_an_intentional_bad_manifest_etag"'}

View File

@ -600,8 +600,7 @@ class FakeHttplibConnection(object):
resp = str(req.get_response(self.app))
resp = "HTTP/1.0 %s" % resp
if six.PY3:
resp = resp.encode("utf-8")
resp = resp.encode("utf-8")
sock = FakeHttplibSocket(resp)
self.http_response = http_client.HTTPResponse(sock)
self.http_response.begin()

View File

@ -16,7 +16,6 @@ import hashlib
from unittest.mock import MagicMock
from unittest.mock import patch
import six
from trove.common import exception
from trove.dns.designate import driver
@ -89,8 +88,7 @@ class DesignateInstanceEntryFactoryTest(trove_testtools.TestCase):
driver.DNS_TTL = 3600
hashed_id = hashlib.md5(instance_id.encode()).digest()
hashed_id = base64.b32encode(hashed_id)
if six.PY3:
hashed_id = hashed_id.decode('ascii')
hashed_id = hashed_id.decode('ascii')
hashed_id_concat = hashed_id[:11].lower()
exp_hostname = ("%s.%s" % (hashed_id_concat, driver.DNS_DOMAIN_NAME))
factory = driver.DesignateInstanceEntryFactory()
@ -109,8 +107,7 @@ class DesignateInstanceEntryFactoryTest(trove_testtools.TestCase):
driver.DNS_TTL = 3600
hashed_id = hashlib.md5(instance_id.encode()).digest()
hashed_id = base64.b32encode(hashed_id)
if six.PY3:
hashed_id = hashed_id.decode('ascii')
hashed_id = hashed_id.decode('ascii')
hashed_id_concat = hashed_id[:11].lower()
exp_hostname = ("%s.%s" %
(hashed_id_concat, driver.DNS_DOMAIN_NAME))[:-1]