Remove dependency fallback for Python 2

... because Python 2 is no longer supported.

Change-Id: I51ad93dd3f2303d1674c15618d08af9ac015a8a9
This commit is contained in:
Takashi Kajinami 2024-05-07 21:32:09 +09:00
parent 47f8c9b3da
commit f73e4fe28d
3 changed files with 6 additions and 22 deletions

View File

@ -15,10 +15,7 @@ import functools
from oslo_serialization import jsonutils from oslo_serialization import jsonutils
from oslo_utils import uuidutils from oslo_utils import uuidutils
import swiftclient import swiftclient
try: # Python3 from urllib.parse import quote_plus
from urllib.parse import quote_plus
except ImportError: # Python2
from urllib import quote_plus
from zaqar import storage from zaqar import storage
from zaqar.storage import errors from zaqar.storage import errors

View File

@ -13,16 +13,12 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
import asyncio
import socket import socket
from oslo_log import log as logging from oslo_log import log as logging
from oslo_utils import netutils from oslo_utils import netutils
try:
import asyncio
except ImportError:
import trollius as asyncio
from zaqar.common import decorators from zaqar.common import decorators
from zaqar.conf import drivers_transport_websocket from zaqar.conf import drivers_transport_websocket
from zaqar.i18n import _ from zaqar.i18n import _

View File

@ -13,7 +13,9 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
import asyncio
import datetime import datetime
import email
import io import io
import sys import sys
@ -25,18 +27,6 @@ from oslo_utils import timeutils
import pytz import pytz
import txaio import txaio
try:
import asyncio
except ImportError:
import trollius as asyncio
try:
import mimetools
Message = mimetools.Message
except ImportError:
import email
Message = email.message_from_binary_file
from zaqar.common import consts from zaqar.common import consts
@ -253,7 +243,8 @@ class NotificationProtocol(asyncio.Protocol):
if self._state == 'HEADERS' and b'\r\n\r\n' in self._data: if self._state == 'HEADERS' and b'\r\n\r\n' in self._data:
headers, self._data = self._data.split(b'\r\n\r\n', 1) headers, self._data = self._data.split(b'\r\n\r\n', 1)
headers = Message(io.BytesIO(headers)) headers = email.message_from_binary_file(io.BytesIO(headers))
# try both cases of content-length for backwards compatibility # try both cases of content-length for backwards compatibility
length = headers.get(b'content-length', length = headers.get(b'content-length',
headers.get('Content-Length')) headers.get('Content-Length'))