diff --git a/zaqar/storage/swift/subscriptions.py b/zaqar/storage/swift/subscriptions.py index 3f9d08eb8..800099399 100644 --- a/zaqar/storage/swift/subscriptions.py +++ b/zaqar/storage/swift/subscriptions.py @@ -15,10 +15,7 @@ import functools from oslo_serialization import jsonutils from oslo_utils import uuidutils import swiftclient -try: # Python3 - from urllib.parse import quote_plus -except ImportError: # Python2 - from urllib import quote_plus +from urllib.parse import quote_plus from zaqar import storage from zaqar.storage import errors diff --git a/zaqar/transport/websocket/driver.py b/zaqar/transport/websocket/driver.py index 98595ea67..d1a04d8f5 100644 --- a/zaqar/transport/websocket/driver.py +++ b/zaqar/transport/websocket/driver.py @@ -13,16 +13,12 @@ # See the License for the specific language governing permissions and # limitations under the License. +import asyncio import socket from oslo_log import log as logging from oslo_utils import netutils -try: - import asyncio -except ImportError: - import trollius as asyncio - from zaqar.common import decorators from zaqar.conf import drivers_transport_websocket from zaqar.i18n import _ diff --git a/zaqar/transport/websocket/protocol.py b/zaqar/transport/websocket/protocol.py index 649d39377..f2db89d0c 100644 --- a/zaqar/transport/websocket/protocol.py +++ b/zaqar/transport/websocket/protocol.py @@ -13,7 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. +import asyncio import datetime +import email import io import sys @@ -25,18 +27,6 @@ from oslo_utils import timeutils import pytz 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 @@ -253,7 +243,8 @@ class NotificationProtocol(asyncio.Protocol): 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 = Message(io.BytesIO(headers)) + headers = email.message_from_binary_file(io.BytesIO(headers)) + # try both cases of content-length for backwards compatibility length = headers.get(b'content-length', headers.get('Content-Length'))