From a18b4e606df9e1a3dd0bc06dcfe0baad2e32a37a Mon Sep 17 00:00:00 2001 From: Flavio Percoco Date: Wed, 3 Sep 2014 10:26:57 +0200 Subject: [PATCH] Use oslo.utils.encodeutils instead of strutils Change-Id: Id8adb40a88d1bbaacbb75e2eeafd723d92d7de29 --- zaqar/queues/storage/redis/messages.py | 6 +++--- zaqar/queues/storage/redis/models.py | 9 ++++----- zaqar/queues/storage/redis/utils.py | 6 +++--- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/zaqar/queues/storage/redis/messages.py b/zaqar/queues/storage/redis/messages.py index 26edb0c7c..4cc967058 100644 --- a/zaqar/queues/storage/redis/messages.py +++ b/zaqar/queues/storage/redis/messages.py @@ -15,11 +15,11 @@ import functools import uuid +from oslo.utils import encodeutils from oslo.utils import timeutils import redis from zaqar.common import decorators -from zaqar.openstack.common import strutils from zaqar.queues import storage from zaqar.queues.storage import errors from zaqar.queues.storage.redis import models @@ -215,7 +215,7 @@ class MessageController(storage.Message): info = { # NOTE(kgriffs): A "None" claim is serialized as an empty str - 'id': strutils.safe_decode(claim[0]) or None, + 'id': encodeutils.safe_decode(claim[0]) or None, 'expires': int(claim[1]), } @@ -310,7 +310,7 @@ class MessageController(storage.Message): offset_msgsets += len(msgset_keys) for msgset_key in msgset_keys: - msgset_key = strutils.safe_decode(msgset_key) + msgset_key = encodeutils.safe_decode(msgset_key) # NOTE(kgriffs): Drive the claim controller GC from # here, because we already know the queue and project diff --git a/zaqar/queues/storage/redis/models.py b/zaqar/queues/storage/redis/models.py index 98aaaa934..8c741f07d 100644 --- a/zaqar/queues/storage/redis/models.py +++ b/zaqar/queues/storage/redis/models.py @@ -16,10 +16,9 @@ import functools import uuid import msgpack +from oslo.utils import encodeutils from oslo.utils import timeutils -from zaqar.openstack.common import strutils - _pack = msgpack.Packer(encoding='utf-8', use_bin_type=True).pack _unpack = functools.partial(msgpack.unpackb, encoding='utf-8') @@ -76,19 +75,19 @@ class Message(object): def from_redis(doc): claim_id = doc[b'c'] if claim_id: - claim_id = strutils.safe_decode(claim_id) + claim_id = encodeutils.safe_decode(claim_id) else: claim_id = None # NOTE(kgriffs): Under Py3K, redis-py converts all strings # into binary. Woohoo! return Message( - id=strutils.safe_decode(doc[b'id']), + id=encodeutils.safe_decode(doc[b'id']), ttl=int(doc[b't']), created=int(doc[b'cr']), expires=int(doc[b'e']), - client_uuid=strutils.safe_decode(doc[b'u']), + client_uuid=encodeutils.safe_decode(doc[b'u']), claim_id=claim_id, claim_expires=int(doc[b'c.e']), diff --git a/zaqar/queues/storage/redis/utils.py b/zaqar/queues/storage/redis/utils.py index 87c3642be..2f68c0898 100644 --- a/zaqar/queues/storage/redis/utils.py +++ b/zaqar/queues/storage/redis/utils.py @@ -17,12 +17,12 @@ import sys import time import uuid +from oslo.utils import encodeutils import redis import six from zaqar.i18n import _ from zaqar.openstack.common import log as logging -from zaqar.openstack.common import strutils from zaqar.queues.storage import errors LOG = logging.getLogger(__name__) @@ -198,7 +198,7 @@ class QueueListCursor(object): def next(self): curr = next(self.queue_iter) queue = self.client.hmget(curr, ['c', 'm']) - return self.denormalizer(queue, strutils.safe_decode(curr)) + return self.denormalizer(queue, encodeutils.safe_decode(curr)) def __next__(self): - return self.next() \ No newline at end of file + return self.next()