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

Python stacktrace.Stacktrace类代码示例

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

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



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

示例1: test_get_composite_hash_uses_exception_value_if_no_type_or_stack

 def test_get_composite_hash_uses_exception_value_if_no_type_or_stack(self):
     interface = Stacktrace(frames=[])
     interface_exc = Exception.to_python(dict(value='bar'))
     result = interface.get_composite_hash({
         'sentry.interfaces.Exception': interface_exc,
     })
     self.assertEquals(result[-1], 'bar')
开发者ID:Superdense,项目名称:sentry,代码行数:7,代码来源:test_stacktrace.py


示例2: to_python

    def to_python(cls, data, slim_frames=True, rust_renormalized=RUST_RENORMALIZED_DEFAULT):
        if not rust_renormalized:
            is_valid, errors = validate_and_default_interface(data, cls.path)
            if not is_valid:
                raise InterfaceValidationError("Invalid exception")

            if not (data.get('type') or data.get('value')):
                raise InterfaceValidationError("No 'type' or 'value' present")

        if get_path(data, 'stacktrace', 'frames', filter=True):
            stacktrace = Stacktrace.to_python(
                data['stacktrace'],
                slim_frames=slim_frames,
                rust_renormalized=rust_renormalized
            )
        else:
            stacktrace = None

        if get_path(data, 'raw_stacktrace', 'frames', filter=True):
            raw_stacktrace = Stacktrace.to_python(
                data['raw_stacktrace'], slim_frames=slim_frames, raw=True,
                rust_renormalized=rust_renormalized
            )
        else:
            raw_stacktrace = None

        type = data.get('type')
        value = data.get('value')

        if not rust_renormalized:
            if isinstance(value, six.string_types):
                if type is None:
                    m = _type_value_re.match(value)
                    if m:
                        type = m.group(1)
                        value = m.group(2).strip()
            elif value is not None:
                value = json.dumps(value)

            value = trim(value, 4096)

        if data.get('mechanism'):
            mechanism = Mechanism.to_python(data['mechanism'],
                                            rust_renormalized=rust_renormalized)
        else:
            mechanism = None

        kwargs = {
            'type': trim(type, 128),
            'value': value,
            'module': trim(data.get('module'), 128),
            'mechanism': mechanism,
            'stacktrace': stacktrace,
            'thread_id': trim(data.get('thread_id'), 40),
            'raw_stacktrace': raw_stacktrace,
        }

        return cls(**kwargs)
开发者ID:getsentry,项目名称:sentry,代码行数:58,代码来源:exception.py


示例3: to_python

    def to_python(cls, data, has_system_frames=None, slim_frames=True):
        if not (data.get('type') or data.get('value')):
            raise InterfaceValidationError("No 'type' or 'value' present")

        if data.get('stacktrace') and data['stacktrace'].get('frames'):
            stacktrace = Stacktrace.to_python(
                data['stacktrace'],
                has_system_frames=has_system_frames,
                slim_frames=slim_frames,
            )
        else:
            stacktrace = None

        if data.get('raw_stacktrace') and data['raw_stacktrace'].get('frames'):
            raw_stacktrace = Stacktrace.to_python(
                data['raw_stacktrace'],
                has_system_frames=has_system_frames,
                slim_frames=slim_frames,
                raw=True
            )
        else:
            raw_stacktrace = None

        type = data.get('type')
        value = data.get('value')
        if not type and ':' in value.split(' ', 1)[0]:
            type, value = value.split(':', 1)
            # in case of TypeError: foo (no space)
            value = value.strip()

        if value is not None and not isinstance(value, six.string_types):
            value = json.dumps(value)
        value = trim(value, 4096)

        mechanism = data.get('mechanism')
        if mechanism is not None:
            if not isinstance(mechanism, dict):
                raise InterfaceValidationError('Bad value for mechanism')
            mechanism = trim(data.get('mechanism'), 4096)
            mechanism.setdefault('type', 'generic')

        kwargs = {
            'type': trim(type, 128),
            'value': value,
            'module': trim(data.get('module'), 128),
            'mechanism': mechanism,
            'stacktrace': stacktrace,
            'thread_id': trim(data.get('thread_id'), 40),
            'raw_stacktrace': raw_stacktrace,
        }

        return cls(**kwargs)
开发者ID:faulkner,项目名称:sentry,代码行数:52,代码来源:exception.py


示例4: test_serialize_returns_frames

 def test_serialize_returns_frames(self):
     interface = Stacktrace.to_python(dict(frames=[{
         'lineno': 1,
         'filename': 'foo.py',
     }]))
     result = interface.to_json()
     assert 'frames' in result
开发者ID:Akashguharoy,项目名称:sentry,代码行数:7,代码来源:test_stacktrace.py


示例5: test_legacy_interface

 def test_legacy_interface(self):
     # Simple test to ensure legacy data works correctly with the ``Frame``
     # objects
     event = self.event
     interface = Stacktrace.to_python(event.data['sentry.interfaces.Stacktrace'])
     assert len(interface.frames) == 1
     assert interface == event.interfaces['sentry.interfaces.Stacktrace']
开发者ID:Akashguharoy,项目名称:sentry,代码行数:7,代码来源:test_stacktrace.py


示例6: test_get_stacktrace_with_filename_function_lineno_and_context

 def test_get_stacktrace_with_filename_function_lineno_and_context(self):
     event = mock.Mock(spec=Event())
     interface = Stacktrace.to_python(
         dict(
             frames=[
                 {
                     'filename': 'foo',
                     'function': 'biz',
                     'lineno': 3,
                     'context_line': '  def foo(r):'
                 },
                 {
                     'filename': 'bar',
                     'function': 'baz',
                     'lineno': 5,
                     'context_line': '    return None'
                 },
             ]
         )
     )
     result = interface.get_stacktrace(event)
     self.assertEquals(
         result,
         'Stacktrace (most recent call last):\n\n  File "foo", line 3, in biz\n    def foo(r):\n  File "bar", line 5, in baz\n    return None'
     )
开发者ID:alshopov,项目名称:sentry,代码行数:25,代码来源:test_stacktrace.py


示例7: test_get_stacktrace_with_module

 def test_get_stacktrace_with_module(self):
     event = mock.Mock(spec=Event())
     interface = Stacktrace.to_python(dict(frames=[{'module': 'foo'}, {'module': 'bar'}]))
     result = interface.get_stacktrace(event)
     self.assertEquals(
         result, 'Stacktrace (most recent call last):\n\n  Module "foo"\n  Module "bar"'
     )
开发者ID:alshopov,项目名称:sentry,代码行数:7,代码来源:test_stacktrace.py


示例8: to_python

    def to_python(cls, data, has_system_frames=None):
        if not (data.get('type') or data.get('value')):
            raise InterfaceValidationError("No 'type' or 'value' present")

        if data.get('stacktrace') and data['stacktrace'].get('frames'):
            stacktrace = Stacktrace.to_python(
                data['stacktrace'],
                has_system_frames=has_system_frames,
            )
        else:
            stacktrace = None

        type = data.get('type')
        value = data.get('value')
        if not type and ':' in value.split(' ', 1)[0]:
            type, value = value.split(':', 1)
            # in case of TypeError: foo (no space)
            value = value.strip()

        if value is not None and not isinstance(value, basestring):
            value = json.dumps(value)
        value = trim(value, 4096)

        kwargs = {
            'type': trim(type, 128),
            'value': value,
            'module': trim(data.get('module'), 128),
            'stacktrace': stacktrace,
        }

        return cls(**kwargs)
开发者ID:zhoupan,项目名称:sentry,代码行数:31,代码来源:exception.py


示例9: get_stacktrace

    def get_stacktrace(self, data):
        try:
            stacktrace = Stacktrace.to_python(data['stacktrace'])
        except KeyError:
            stacktrace = None

        return stacktrace
开发者ID:vperron,项目名称:sentry,代码行数:7,代码来源:processor.py


示例10: test_over_max

    def test_over_max(self):
        values = []
        for n in xrange(5):
            values.append({
                'filename': 'frame %d' % n,
                'vars': {'foo': 'bar'},
                'context_line': 'b',
                'pre_context': ['a'],
                'post_context': ['c'],
            })
        interface = Stacktrace.to_python({'frames': values})
        slim_frame_data(interface, 4)

        assert len(interface.frames) == 5

        for value, num in zip(interface.frames[:2], xrange(2)):
            assert value.filename == 'frame %d' % num
            assert value.vars is not None
            assert value.pre_context is not None
            assert value.post_context is not None

        for value, num in zip(interface.frames[3:], xrange(3, 5)):
            assert value.filename == 'frame %d' % num
            assert value.vars is not None
            assert value.pre_context is not None
            assert value.post_context is not None

        value = interface.frames[2]
        assert value.filename == 'frame 2'
        assert not value.vars
        assert not value.pre_context
        assert not value.post_context
开发者ID:Akashguharoy,项目名称:sentry,代码行数:32,代码来源:test_stacktrace.py


示例11: test_does_not_overwrite_filename

 def test_does_not_overwrite_filename(self):
     interface = Stacktrace.to_python(
         dict(frames=[{"lineno": 1, "filename": "foo.js", "abs_path": "http://foo.com/foo.js"}])
     )
     frame = interface.frames[0]
     assert frame.filename == "foo.js"
     assert frame.abs_path == "http://foo.com/foo.js"
开发者ID:songyi199111,项目名称:sentry,代码行数:7,代码来源:test_stacktrace.py


示例12: test_get_stacktrace_with_filename_and_function

 def test_get_stacktrace_with_filename_and_function(self):
     event = mock.Mock(spec=Event())
     interface = Stacktrace.to_python(
         dict(frames=[{"filename": "foo", "function": "biz"}, {"filename": "bar", "function": "baz"}])
     )
     result = interface.get_stacktrace(event)
     self.assertEquals(result, 'Stacktrace (most recent call last):\n\n  File "foo", in biz\n  File "bar", in baz')
开发者ID:songyi199111,项目名称:sentry,代码行数:7,代码来源:test_stacktrace.py


示例13: generate_culprit

def generate_culprit(data, platform=None):
    culprit = ''

    try:
        stacktraces = [
            e['stacktrace'] for e in data['sentry.interfaces.Exception']['values']
            if e.get('stacktrace')
        ]
    except KeyError:
        stacktrace = data.get('sentry.interfaces.Stacktrace')
        if stacktrace:
            stacktraces = [stacktrace]
        else:
            stacktraces = None

    if not stacktraces:
        if 'sentry.interfaces.Http' in data:
            culprit = data['sentry.interfaces.Http'].get('url', '')
    else:
        from sentry.interfaces.stacktrace import Stacktrace
        culprit = Stacktrace.to_python(stacktraces[-1]).get_culprit_string(
            platform=platform,
        )

    return truncatechars(culprit, MAX_CULPRIT_LENGTH)
开发者ID:alshopov,项目名称:sentry,代码行数:25,代码来源:event_manager.py


示例14: to_python

    def to_python(cls, data, has_system_frames=None, slim_frames=True):
        if not (data.get("type") or data.get("value")):
            raise InterfaceValidationError("No 'type' or 'value' present")

        if data.get("stacktrace") and data["stacktrace"].get("frames"):
            stacktrace = Stacktrace.to_python(
                data["stacktrace"], has_system_frames=has_system_frames, slim_frames=slim_frames
            )
        else:
            stacktrace = None

        if data.get("raw_stacktrace") and data["raw_stacktrace"].get("frames"):
            raw_stacktrace = Stacktrace.to_python(
                data["raw_stacktrace"], has_system_frames=has_system_frames, slim_frames=slim_frames
            )
        else:
            raw_stacktrace = None

        type = data.get("type")
        value = data.get("value")
        if not type and ":" in value.split(" ", 1)[0]:
            type, value = value.split(":", 1)
            # in case of TypeError: foo (no space)
            value = value.strip()

        if value is not None and not isinstance(value, six.string_types):
            value = json.dumps(value)
        value = trim(value, 4096)

        mechanism = data.get("mechanism")
        if mechanism is not None:
            if not isinstance(mechanism, dict):
                raise InterfaceValidationError("Bad value for mechanism")
            mechanism = trim(data.get("mechanism"), 4096)
            mechanism.setdefault("type", "generic")

        kwargs = {
            "type": trim(type, 128),
            "value": value,
            "module": trim(data.get("module"), 128),
            "mechanism": mechanism,
            "stacktrace": stacktrace,
            "thread_id": trim(data.get("thread_id"), 40),
            "raw_stacktrace": raw_stacktrace,
        }

        return cls(**kwargs)
开发者ID:ForkRepo,项目名称:sentry,代码行数:47,代码来源:exception.py


示例15: test_to_html_response

 def test_to_html_response(self, get_traceback):
     event = mock.Mock(spec=Event())
     event.message = 'foo'
     get_traceback.return_value = 'bar'
     interface = Stacktrace.to_python(dict(frames=[{'lineno': 1, 'filename': 'foo.py'}]))
     result = interface.to_html(event)
     get_traceback.assert_called_once_with(event, newest_first=False)
     self.assertTrue('<div class="module">' in result)
开发者ID:Superdense,项目名称:sentry,代码行数:8,代码来源:test_stacktrace.py


示例16: get_stacktraces

    def get_stacktraces(self, data):
        exceptions = get_path(data, 'exception', 'values', filter=True, default=())
        stacktraces = [e['stacktrace'] for e in exceptions if e.get('stacktrace')]

        if 'stacktrace' in data:
            stacktraces.append(data['stacktrace'])

        return [(s, Stacktrace.to_python(s)) for s in stacktraces]
开发者ID:Kayle009,项目名称:sentry,代码行数:8,代码来源:processor.py


示例17: test_get_traceback_response

 def test_get_traceback_response(self, get_stacktrace):
     event = mock.Mock(spec=Event())
     event.message = "foo"
     get_stacktrace.return_value = "bar"
     interface = Stacktrace.to_python(dict(frames=[{"lineno": 1, "filename": "foo.py"}]))
     result = interface.get_traceback(event)
     get_stacktrace.assert_called_once_with(event, newest_first=None)
     self.assertEquals(result, "foo\n\nbar")
开发者ID:songyi199111,项目名称:sentry,代码行数:8,代码来源:test_stacktrace.py


示例18: test_allows_abs_path_without_filename

 def test_allows_abs_path_without_filename(self):
     interface = Stacktrace.to_python(dict(frames=[{
         'lineno': 1,
         'abs_path': 'foo/bar/baz.py',
     }]))
     frame = interface.frames[0]
     assert frame.filename == 'foo/bar/baz.py'
     assert frame.abs_path == frame.filename
开发者ID:Akashguharoy,项目名称:sentry,代码行数:8,代码来源:test_stacktrace.py


示例19: test_ignores_results_with_empty_path

 def test_ignores_results_with_empty_path(self):
     interface = Stacktrace.to_python(dict(frames=[{
         'lineno': 1,
         'filename': 'http://foo.com',
     }]))
     frame = interface.frames[0]
     assert frame.filename == 'http://foo.com'
     assert frame.abs_path == frame.filename
开发者ID:Akashguharoy,项目名称:sentry,代码行数:8,代码来源:test_stacktrace.py


示例20: test_coerces_url_filenames

 def test_coerces_url_filenames(self):
     interface = Stacktrace.to_python(dict(frames=[{
         'lineno': 1,
         'filename': 'http://foo.com/foo.js',
     }]))
     frame = interface.frames[0]
     assert frame.filename == '/foo.js'
     assert frame.abs_path == 'http://foo.com/foo.js'
开发者ID:Akashguharoy,项目名称:sentry,代码行数:8,代码来源:test_stacktrace.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python processor.fetch_file函数代码示例发布时间:2022-05-27
下一篇:
Python stacktrace.Frame类代码示例发布时间: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