• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python pickle.loads函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中sentry.utils.compat.pickle.loads函数的典型用法代码示例。如果您正苦于以下问题:Python loads函数的具体用法?Python loads怎么用?Python loads使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了loads函数的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: process

    def process(self, key):
        client = self.cluster.get_routing_client()
        lock_key = self._make_lock_key(key)
        # prevent a stampede due to the way we use celery etas + duplicate
        # tasks
        if not client.set(lock_key, '1', nx=True, ex=10):
            return

        with self.cluster.map() as conn:
            values = conn.hgetall(key)
            conn.delete(key)

        if not values.value:
            return

        model = import_string(values.value['m'])
        filters = pickle.loads(values.value['f'])
        incr_values = {}
        extra_values = {}
        for k, v in values.value.iteritems():
            if k.startswith('i+'):
                incr_values[k[2:]] = int(v)
            elif k.startswith('e+'):
                extra_values[k[2:]] = pickle.loads(v)

        super(RedisBuffer, self).process(model, incr_values, filters, extra_values)
开发者ID:pauloschilling,项目名称:sentry,代码行数:26,代码来源:redis.py


示例2: process

    def process(self, key):
        client = self.cluster.get_routing_client()
        lock_key = self._make_lock_key(key)
        # prevent a stampede due to the way we use celery etas + duplicate
        # tasks
        if not client.set(lock_key, '1', nx=True, ex=10):
            metrics.incr('buffer.revoked', tags={'reason': 'locked'})
            self.logger.info('Skipped process on %s; unable to get lock', key)
            return

        conn = self.cluster.get_local_client_for_key(key)
        pipe = conn.pipeline()
        pipe.hgetall(key)
        pipe.zrem(self.pending_key, key)
        pipe.delete(key)
        values = pipe.execute()[0]

        if not values:
            metrics.incr('buffer.revoked', tags={'reason': 'empty'})
            self.logger.info('Skipped process on %s; no values found', key)
            return

        model = import_string(values['m'])
        filters = pickle.loads(values['f'])
        incr_values = {}
        extra_values = {}
        for k, v in values.iteritems():
            if k.startswith('i+'):
                incr_values[k[2:]] = int(v)
            elif k.startswith('e+'):
                extra_values[k[2:]] = pickle.loads(v)

        super(RedisBuffer, self).process(model, incr_values, filters, extra_values)
开发者ID:daevaorn,项目名称:sentry,代码行数:33,代码来源:redis.py


示例3: process

    def process(self, key):
        lock_key = self._make_lock_key(key)
        # prevent a stampede due to the way we use celery etas + duplicate
        # tasks
        if not self.conn.setnx(lock_key, '1'):
            return
        self.conn.expire(lock_key, 10)

        with self.conn.map() as conn:
            values = conn.hgetall(key)
            conn.delete(key)

        if not values:
            return

        model = import_string(values['m'])
        filters = pickle.loads(values['f'])
        incr_values = {}
        extra_values = {}
        for k, v in values.iteritems():
            if k.startswith('i+'):
                incr_values[k[2:]] = int(v)
            elif k.startswith('e+'):
                extra_values[k[2:]] = pickle.loads(v)

        super(RedisBuffer, self).process(model, incr_values, filters, extra_values)
开发者ID:BlueMoebius,项目名称:sentry,代码行数:26,代码来源:redis.py


示例4: to_python

 def to_python(self, value):
     if isinstance(value, basestring) and value:
         try:
             value = pickle.loads(base64.b64decode(value).decode('zlib'))
         except Exception, e:
             logger.exception(e)
             return {}
开发者ID:asavoy,项目名称:sentry,代码行数:7,代码来源:models.py


示例5: process

    def process(self, model, columns, filters, extra=None):
        results = {}
        with self.conn.map() as conn:
            for column, amount in columns.iteritems():
                key = self._make_key(model, filters, column)
                results[column] = conn.getset(key, 0)
                conn.expire(key, 60)  # drop expiration as it was just emptied

            hash_key = self._make_extra_key(model, filters)
            extra_results = conn.hgetall(hash_key)
            conn.delete(hash_key)

        # We combine the stored extra values with whatever was passed.
        # This ensures that static values get updated to their latest value,
        # and dynamic values (usually query expressions) are still dynamic.
        if extra_results:
            if not extra:
                extra = {}
            for key, value in extra_results.iteritems():
                if not value:
                    continue
                extra[key] = pickle.loads(str(value))

        # Filter out empty or zero'd results to avoid a potentially unnescesary update
        results = dict((k, int(v)) for k, v in results.iteritems() if int(v or 0) > 0)
        if not results:
            return
        super(RedisBuffer, self).process(model, results, filters, extra)
开发者ID:DamianZaremba,项目名称:sentry,代码行数:28,代码来源:redis.py


示例6: to_python

 def to_python(self, value):
     if isinstance(value, basestring) and value:
         try:
             value = pickle.loads(decompress(value))
         except Exception, e:
             logger.exception(e)
             return {}
开发者ID:HengeSense,项目名称:sentry,代码行数:7,代码来源:gzippeddict.py


示例7: process

    def process(self, model, columns, filters, extra=None):
        lock_key = self._make_lock_key(model, filters)
        call_args = (lock_key, '1', self.delay)
        if not self._tnt.call('box.sentry_buffer.setnx', call_args):
            return

        results = {}
        for column, amount in columns.iteritems():
            key = self._make_key(model, filters, column)
            call_args = (key, '0', str(self.key_expire))
            response = self._tnt.call('box.sentry_buffer.getset', call_args)
            if len(response) == 0:
                continue
            value = int(response[0][0])
            results[column] = value

        hash_key = self._make_extra_key(model, filters)
        call_args = (hash_key,)
        extra_results = self._tnt.call('box.sentry_buffer.hgetalldelete',
                                       call_args)

        if len(extra_results):
            if not extra:
                extra = {}
            for key, value in extra_results:
                if not value:
                    continue
                extra[key] = pickle.loads(str(value))

        # Filter out empty or zero'd results to avoid a potentially unnecessary update
        results = dict((k, int(v)) for k, v in results.iteritems() if int(v or 0) > 0)
        if not results:
            return
        super(TarantoolBuffer, self).process(model, results, filters, extra)
开发者ID:toidi,项目名称:tarantool-python-utils,代码行数:34,代码来源:sentry.py


示例8: _process_single_incr

    def _process_single_incr(self, key):
        client = self.cluster.get_routing_client()
        lock_key = self._make_lock_key(key)
        # prevent a stampede due to the way we use celery etas + duplicate
        # tasks
        if not client.set(lock_key, '1', nx=True, ex=10):
            metrics.incr('buffer.revoked', tags={'reason': 'locked'})
            self.logger.debug('buffer.revoked.locked', extra={'redis_key': key})
            return

        pending_key = self._make_pending_key_from_key(key)

        try:
            conn = self.cluster.get_local_client_for_key(key)
            pipe = conn.pipeline()
            pipe.hgetall(key)
            pipe.zrem(pending_key, key)
            pipe.delete(key)
            values = pipe.execute()[0]

            if not values:
                metrics.incr('buffer.revoked', tags={'reason': 'empty'})
                self.logger.debug('buffer.revoked.empty', extra={'redis_key': key})
                return

            model = import_string(values.pop('m'))
            if values['f'].startswith('{'):
                filters = self._load_values(json.loads(values.pop('f')))
            else:
                # TODO(dcramer): legacy pickle support - remove in Sentry 9.1
                filters = pickle.loads(values.pop('f'))

            incr_values = {}
            extra_values = {}
            for k, v in six.iteritems(values):
                if k.startswith('i+'):
                    incr_values[k[2:]] = int(v)
                elif k.startswith('e+'):
                    if v.startswith('['):
                        extra_values[k[2:]] = self._load_value(json.loads(v))
                    else:
                        # TODO(dcramer): legacy pickle support - remove in Sentry 9.1
                        extra_values[k[2:]] = pickle.loads(v)

            super(RedisBuffer, self).process(model, incr_values, filters, extra_values)
        finally:
            client.delete(lock_key)
开发者ID:alexandrul,项目名称:sentry,代码行数:47,代码来源:redis.py


示例9: to_python

 def to_python(self, value):
     if isinstance(value, six.string_types) and value:
         try:
             value = pickle.loads(decompress(value))
         except Exception as e:
             logger.exception(e)
             return {}
     elif not value:
         return {}
     return value
开发者ID:ForkRepo,项目名称:sentry,代码行数:10,代码来源:gzippeddict.py


示例10: test_handles_gettext_lazy

    def test_handles_gettext_lazy(self):
        def fake_gettext(to_translate):
            return u'Igpay Atinlay'

        fake_gettext_lazy = lazy(fake_gettext, str)

        self.assertEquals(
            pickle.loads(pickle.dumps(
                    transform(fake_gettext_lazy("something")))),
            u'Igpay Atinlay')
开发者ID:olarcheveque,项目名称:django-sentry,代码行数:10,代码来源:tests.py


示例11: to_python

    def to_python(self, value):
        if isinstance(value, six.string_types) and value:
            try:
                value = pickle.loads(decompress(value))
            except Exception as e:
                logger.exception(e)
                value = {}
        elif not value:
            value = {}

        if 'node_id' in value:
            node_id = value.pop('node_id')
            data = None
        else:
            node_id = None
            data = value

        return NodeData(self, node_id, data)
开发者ID:NuttasitBoonwat,项目名称:sentry,代码行数:18,代码来源:node.py


示例12: to_python

    def to_python(self, value):
        node_id = None
        # If value is a string, we assume this is a value we've loaded from the
        # database, it should be decompressed/unpickled, and we should end up
        # with a dict.
        if value and isinstance(value, six.string_types):
            try:
                value = pickle.loads(decompress(value))
            except Exception as e:
                # TODO this is a bit dangerous as a failure to read/decode the
                # node_id will end up with this record being replaced with an
                # empty value under a new key, potentially orphaning an
                # original value in nodestore. OTOH if we can't decode the info
                # here, the node was already effectively orphaned.
                logger.exception(e)
                value = None

        if value:
            if 'node_id' in value:
                node_id = value.pop('node_id')
                # If the value is now empty, that means that it only had the
                # node_id in it, which means that we should be looking to *load*
                # the event body from nodestore. If it does have other stuff in
                # it, that means we got an event body with a precomputed id in
                # it, and we want to *save* the rest of the body to nodestore.
                if value == {}:
                    value = None
        else:
            # Either we were passed a null/empty value in the constructor, or
            # we failed to decode the value from the database so we have no id
            # to load data from, and no data to save.
            value = None

        if value is not None and self.wrapper is not None:
            value = self.wrapper(value)

        return NodeData(self, node_id, value)
开发者ID:getsentry,项目名称:sentry,代码行数:37,代码来源:node.py


示例13: import

import warnings

from django.utils.text import slugify
from exam import fixture
from uuid import uuid4

from sentry.models import (
    Activity, Event, Group, Organization, OrganizationMember,
    OrganizationMemberTeam, Project, Team, User
)
from sentry.utils.compat import pickle
from sentry.utils.strings import decompress


# an example data blog from Sentry 5.4.1 (db level)
LEGACY_DATA = pickle.loads(decompress("""eJy9WW1v20YS/q5fwfqLpECluMvXFSzjgKK9BrikByR3XwyDXpFLmjVFsnxxbAT57zczS0rUS+LGrU8IYu3s2+yzM8/MrGZxxSYfpo0q2vrJzIpW1YmMVGO+U00jUzWdVHwyiysbBm13IgdaH++yxoB/0mhV0xp9p5GqQtWyVbHRNVmRGre3tXxQBQ26vYW57qT5MK1kLbcNtLzJLK/8SQOyVqYoCVAicJB6bGsJEmahBoz0fGpMWacPKOU4kKFiy/80qm6WcQSLqnppPmR128lcFQ/NUp9sucmKJSmCM52JhO1AIWy42Lhr26pZLZdqE9luYtuKucyxWCJiJSPXEcIPNrFkbJXYjm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PI4K/Vpxif6KpPXRbPyga/K/w6n19bN/iQwaAY3rOVjxQLNt+/u/mYbF+CEiQyf6Pr/jd1Q4IM6heRGnGPxS3NPT49fNZlSZm7j2HwcsDiX8QKJ8QVSE/0k+ndq6/nIzCa/hmE+fQC0D8xMF+jHlA432UfASHxym+ctBGnPD9uyNYCe/J/eFgN6JVFxylqf3dQwGp4yOCgFD6fwWFl/NIMLhCvmsEJ6/kMTuhKFF2H3o5Rm8v/yrzb1+5oq9HGwiBBVfvK0OSoH8J068sVLWYfJYEnL2hMHKeDZ5lCjBND4Y2oQhevYlf7zCkDE4f1DtRNfX4CXtcqM87iMJFZ3ldOQowJAEIUWMFU1XVZ/4CYgF9+i5iJMPaJgaaJvj2bL2gBNjAuPgkh4XIo0zXhXuqi/4qe5u3vIN3xDxXccnZUyi1cNttWZQ2l4hM9xusinmJPdZ+GtWrKroaIb/TDUN2Qlg2rMiP/4NY+sQb8whCfHcLQWK+NaRhimAjD6YpOt6Nl/NFFPWbtjOaPakRO2XQYYqHZAvfBVPzhATOd/vzGvhc6jRl9/zEr5mhInNGjRhji80c/9wU/53Dm6GX64NSv5NKDYY8UFt17nVB4oouvF6nVH10GSPar7Arg9Xr/ywmjV8Rz6HJ6Txx+QDi5gN07mXK4p4h+OGd6Y30RJOGEan8ZKLD1kLiMeoEDh+td8GCgu3O7A4S4t3c0zoeYPKeu4FtecHyA2REYmP6VRVPC/fUejiK973yGeQnnu7IJvsimMf8Hr5plBQ=="""))


class Fixtures(object):
    @fixture
    def projectkey(self):
        return self.create_project_key(project=self.project)

    @fixture
    def user(self):
        return self.create_user('[email protected]', is_superuser=True)

    @fixture
    def organization(self):
        # XXX(dcramer): ensure that your org slug doesnt match your team slug
        # and the same for your project slug
开发者ID:AyrtonRicardo,项目名称:sentry,代码行数:31,代码来源:fixtures.py


示例14: HttpResponseForbidden

    logger = logging.getLogger('sentry.server')

    try:
        try:
            data = base64.b64decode(data).decode('zlib')
        except zlib.error:
            data = base64.b64decode(data)
    except Exception, e:
        # This error should be caught as it suggests that there's a
        # bug somewhere in the client's code.
        logger.exception('Bad data received')
        return HttpResponseForbidden('Bad data decoding request (%s, %s)' % (e.__class__.__name__, e))

    try:
        if format == 'pickle':
            data = pickle.loads(data)
        elif format == 'json':
            data = json.loads(data)
    except Exception, e:
        # This error should be caught as it suggests that there's a
        # bug somewhere in the client's code.
        logger.exception('Bad data received')
        fh = open('/tmp/bad_sentry_data.txt', 'a')
        print >>fh, 'Bad data reconstructing object (%s, %s)' % (e.__class__.__name__, e)
        print >>fh, data
        print >>fh, '#' * 80, '\n\n'
        fh.close()

        return HttpResponseForbidden('Bad data reconstructing object (%s, %s)' % (e.__class__.__name__, e))

    # XXX: ensure keys are coerced to strings
开发者ID:tbarbugli,项目名称:sentry_fork,代码行数:31,代码来源:views.py


示例15: to_python

 def to_python(self, value):
     if isinstance(value, basestring) and value:
         value = pickle.loads(base64.b64decode(value).decode('zlib'))
     elif not value:
         return {}
     return value
开发者ID:Torkn,项目名称:django-sentry,代码行数:6,代码来源:models.py


示例16: decode

 def decode(self, value):
     return pickle.loads(zlib.decompress(value))
开发者ID:280185386,项目名称:sentry,代码行数:2,代码来源:codecs.py



注:本文中的sentry.utils.compat.pickle.loads函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python cursors.Cursor类代码示例发布时间:2022-05-27
下一篇:
Python pickle.dumps函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap