Merge "Decode bytes to strings"
This commit is contained in:
commit
6e6deabc9f
@ -157,8 +157,8 @@ class SubscriptionEnvelope(object):
|
|||||||
is_confirmed = bool(self.confirmed)
|
is_confirmed = bool(self.confirmed)
|
||||||
basic_msg = {
|
basic_msg = {
|
||||||
'id': self.id,
|
'id': self.id,
|
||||||
'source': self.source.decode(),
|
'source': encodeutils.safe_decode(self.source),
|
||||||
'subscriber': self.subscriber.decode(),
|
'subscriber': encodeutils.safe_decode(self.subscriber),
|
||||||
'ttl': self.ttl,
|
'ttl': self.ttl,
|
||||||
'age': now - created,
|
'age': now - created,
|
||||||
'options': self.options,
|
'options': self.options,
|
||||||
@ -318,8 +318,8 @@ def _hmap_to_subenv_kwargs(hmap):
|
|||||||
# into binary. Woohoo!
|
# into binary. Woohoo!
|
||||||
return {
|
return {
|
||||||
'id': encodeutils.safe_decode(hmap[b'id']),
|
'id': encodeutils.safe_decode(hmap[b'id']),
|
||||||
'source': hmap[b's'],
|
'source': encodeutils.safe_decode(hmap[b's']),
|
||||||
'subscriber': hmap[b'u'],
|
'subscriber': encodeutils.safe_decode(hmap[b'u']),
|
||||||
'ttl': int(hmap[b't']),
|
'ttl': int(hmap[b't']),
|
||||||
'expires': int(hmap[b'e']),
|
'expires': int(hmap[b'e']),
|
||||||
'options': _unpack(hmap[b'o']),
|
'options': _unpack(hmap[b'o']),
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
import functools
|
import functools
|
||||||
|
|
||||||
import msgpack
|
import msgpack
|
||||||
|
from oslo_utils import encodeutils
|
||||||
from oslo_utils import timeutils
|
from oslo_utils import timeutils
|
||||||
from oslo_utils import uuidutils
|
from oslo_utils import uuidutils
|
||||||
import redis
|
import redis
|
||||||
@ -78,8 +79,8 @@ class SubscriptionController(base.Subscription):
|
|||||||
is_confirmed = int(record[5])
|
is_confirmed = int(record[5])
|
||||||
ret = {
|
ret = {
|
||||||
'id': sid,
|
'id': sid,
|
||||||
'source': record[0].decode(),
|
'source': encodeutils.safe_decode(record[0]),
|
||||||
'subscriber': record[1].decode(),
|
'subscriber': encodeutils.safe_decode(record[1]),
|
||||||
'ttl': ttl,
|
'ttl': ttl,
|
||||||
'age': now - created,
|
'age': now - created,
|
||||||
'options': self._unpacker(record[4]),
|
'options': self._unpacker(record[4]),
|
||||||
@ -167,7 +168,7 @@ class SubscriptionController(base.Subscription):
|
|||||||
# the subscription but the id is still there. So let's
|
# the subscription but the id is still there. So let's
|
||||||
# delete the id for clean up.
|
# delete the id for clean up.
|
||||||
self._client.zrem(subset_key, s_id)
|
self._client.zrem(subset_key, s_id)
|
||||||
if subscription[1].decode() == subscriber:
|
if encodeutils.safe_decode(subscription[1]) == subscriber:
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
except redis.exceptions.ResponseError:
|
except redis.exceptions.ResponseError:
|
||||||
@ -251,7 +252,7 @@ class SubscriptionController(base.Subscription):
|
|||||||
for s_id in sub_ids:
|
for s_id in sub_ids:
|
||||||
subscription = self._client.hmget(s_id,
|
subscription = self._client.hmget(s_id,
|
||||||
['s', 'u', 't', 'o', 'c'])
|
['s', 'u', 't', 'o', 'c'])
|
||||||
if subscription[1].decode() == subscriber:
|
if encodeutils.safe_decode(subscription[1]) == subscriber:
|
||||||
subscription = SubscriptionEnvelope.from_redis(s_id,
|
subscription = SubscriptionEnvelope.from_redis(s_id,
|
||||||
self._client)
|
self._client)
|
||||||
now = timeutils.utcnow_ts()
|
now = timeutils.utcnow_ts()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user