当前位置: 首页>>代码示例>>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;未经允许,请勿转载。