當前位置: 首頁>>代碼示例>>Python>>正文


Python _compat.nativestr方法代碼示例

本文整理匯總了Python中redis._compat.nativestr方法的典型用法代碼示例。如果您正苦於以下問題:Python _compat.nativestr方法的具體用法?Python _compat.nativestr怎麽用?Python _compat.nativestr使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在redis._compat的用法示例。


在下文中一共展示了_compat.nativestr方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: connect_to

# 需要導入模塊: from redis import _compat [as 別名]
# 或者: from redis._compat import nativestr [as 別名]
def connect_to(self, address):
        self.host, self.port = address
        super(SentinelManagedConnection, self).connect()
        if self.connection_pool.check_connection:
            self.send_command('PING')
            if nativestr(self.read_response()) != 'PONG':
                raise ConnectionError('PING failed') 
開發者ID:leancloud,項目名稱:satori,代碼行數:9,代碼來源:sentinel.py

示例2: bool_ok

# 需要導入模塊: from redis import _compat [as 別名]
# 或者: from redis._compat import nativestr [as 別名]
def bool_ok(response):
    return nativestr(response) == 'OK' 
開發者ID:RedisBloom,項目名稱:redisbloom-py,代碼行數:4,代碼來源:client.py

示例3: __init__

# 需要導入模塊: from redis import _compat [as 別名]
# 或者: from redis._compat import nativestr [as 別名]
def __init__(self, args):
        response = dict(zip(map(nativestr, args[::2]), args[1::2]))
        self.capacity = response['Capacity']
        self.size = response['Size']
        self.filterNum = response['Number of filters']
        self.insertedNum = response['Number of items inserted']
        self.expansionRate = response['Expansion rate'] 
開發者ID:RedisBloom,項目名稱:redisbloom-py,代碼行數:9,代碼來源:client.py

示例4: __init__

# 需要導入模塊: from redis import _compat [as 別名]
# 或者: from redis._compat import nativestr [as 別名]
def __init__(self, args):
        response = dict(zip(map(nativestr, args[::2]), args[1::2]))
        self.rules = response['rules']
        self.sourceKey = response['sourceKey']
        self.chunkCount = response['chunkCount']
        self.memory_usage = response['memoryUsage']
        self.total_samples = response['totalSamples']
        self.labels = list_to_dict(response['labels'])
        self.retention_msecs = response['retentionTime']
        self.lastTimeStamp = response['lastTimestamp']
        self.first_time_stamp = response['firstTimestamp']
        self.maxSamplesPerChunk = response['maxSamplesPerChunk'] 
開發者ID:RedisTimeSeries,項目名稱:redistimeseries-py,代碼行數:14,代碼來源:client.py

示例5: list_to_dict

# 需要導入模塊: from redis import _compat [as 別名]
# 或者: from redis._compat import nativestr [as 別名]
def list_to_dict(aList):
    return {nativestr(aList[i][0]):nativestr(aList[i][1])
                for i in range(len(aList))} 
開發者ID:RedisTimeSeries,項目名稱:redistimeseries-py,代碼行數:5,代碼來源:client.py

示例6: parse_m_range

# 需要導入模塊: from redis import _compat [as 別名]
# 或者: from redis._compat import nativestr [as 別名]
def parse_m_range(response):
    res = []
    for item in response:
        res.append({ nativestr(item[0]) : [list_to_dict(item[1]),
                                parse_range(item[2])]})
    return res 
開發者ID:RedisTimeSeries,項目名稱:redistimeseries-py,代碼行數:8,代碼來源:client.py

示例7: parse_m_get

# 需要導入模塊: from redis import _compat [as 別名]
# 或者: from redis._compat import nativestr [as 別名]
def parse_m_get(response):
    res = []
    for item in response:
        if item[2] == []:
            res.append({ nativestr(item[0]) : [list_to_dict(item[1]), None, None]})
        else:
            res.append({ nativestr(item[0]) : [list_to_dict(item[1]),
                                int(item[2][0]), float(item[2][1])]})

    return res 
開發者ID:RedisTimeSeries,項目名稱:redistimeseries-py,代碼行數:12,代碼來源:client.py

示例8: parseToList

# 需要導入模塊: from redis import _compat [as 別名]
# 或者: from redis._compat import nativestr [as 別名]
def parseToList(response):
    res = []
    for item in response:
        res.append(nativestr(item))
    return res 
開發者ID:RedisTimeSeries,項目名稱:redistimeseries-py,代碼行數:7,代碼來源:client.py

示例9: handle_message

# 需要導入模塊: from redis import _compat [as 別名]
# 或者: from redis._compat import nativestr [as 別名]
def handle_message(self, response, ignore_subscribe_messages=False):
        '''
        Replacement for the default PubSub message handler, use the threadpool for handling
        Mostly copied from http://github.com/andymccurdy/redis-py/master/redis/client.py
        '''
        message_type = nativestr(response[0])
        if message_type == 'pmessage':
            message = {
                'type': message_type,
                'pattern': response[1],
                'channel': response[2],
                'data': response[3],
            }
        else:
            message = {
                'type': message_type,
                'pattern': None,
                'channel': response[1],
                'data': response[2],
            }

        # if this is an unsubscribe message, remove it from memory
        if message_type in self.UNSUBSCRIBE_MESSAGE_TYPES:
            subscribed_dict = None
            if message_type == 'punsubscribe':
                subscribed_dict = self.patterns
            else:
                subscribed_dict = self.channels
            try:
                del subscribed_dict[message['channel']]
            except KeyError:
                pass

        if message_type in self.PUBLISH_MESSAGE_TYPES:
            # if there's a message handler, invoke it
            handler = None
            if message_type == 'pmessage':
                handler = self.patterns.get(message['pattern'], None)
            else:
                handler = self.channels.get(message['channel'], None)
            if handler:
                res = self.threadpool.apply_async(handler, [message])
                return None

        else:
            # this is a subscribe/unsubscribe message. ignore if we don't
            # want them
            if ignore_subscribe_messages or self.ignore_subscribe_messages:
                return None

        return message 
開發者ID:hulu,項目名稱:monaco,代碼行數:53,代碼來源:async_pubsub.py


注:本文中的redis._compat.nativestr方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。