本文整理汇总了Python中sentry.utils.safe.get_path函数的典型用法代码示例。如果您正苦于以下问题:Python get_path函数的具体用法?Python get_path怎么用?Python get_path使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_path函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: signal_from_data
def signal_from_data(data):
exceptions = get_path(data, 'exception', 'values', filter=True)
signal = get_path(exceptions, 0, 'mechanism', 'meta', 'signal', 'number')
if signal is not None:
return int(signal)
return None
开发者ID:getsentry,项目名称:sentry,代码行数:7,代码来源:utils.py
示例2: get_frames
def get_frames(self, with_functions=False):
from sentry.stacktraces.functions import get_function_name_for_frame
if self._frames is None:
self._frames = []
def _push_frame(frame):
platform = frame.get('platform') or self.event.get('platform')
func = get_function_name_for_frame(frame, platform)
self._frames.append({
'function': func or '<unknown>',
'path': frame.get('abs_path') or frame.get('filename'),
'module': frame.get('module'),
'family': get_behavior_family_for_platform(platform),
'package': frame.get('package'),
})
have_errors = False
for exc in get_path(self.event, 'exception', 'values', filter=True) or ():
for frame in get_path(exc, 'stacktrace', 'frames', filter=True) or ():
_push_frame(frame)
have_errors = True
if not have_errors:
frames = get_path(self.event, 'stacktrace', 'frames', filter=True)
if not frames:
threads = get_path(self.event, 'threads', 'values', filter=True)
if threads and len(threads) == 1:
frames = get_path(threads, 0, 'stacktrace', 'frames')
for frame in frames or ():
_push_frame(frame)
return self._frames
开发者ID:getsentry,项目名称:sentry,代码行数:32,代码来源:fingerprinting.py
示例3: test_get_path_list
def test_get_path_list(self):
arr = [1, 2]
assert get_path(arr, 1) == 2
assert get_path(arr, -1) == 2
assert get_path(arr, 2) is None
assert get_path(arr, '1') is None
assert get_path([], 1) is None
开发者ID:yaoqi,项目名称:sentry,代码行数:7,代码来源:test_safe.py
示例4: find_stacktraces_in_data
def find_stacktraces_in_data(data, include_raw=False):
"""Finds all stracktraces in a given data blob and returns it
together with some meta information.
If `include_raw` is True, then also raw stacktraces are included.
"""
rv = []
def _report_stack(stacktrace, container):
if not stacktrace or not get_path(stacktrace, 'frames', filter=True):
return
platforms = set(
frame.get('platform') or data.get('platform')
for frame in get_path(stacktrace, 'frames', filter=True, default=())
)
rv.append(StacktraceInfo(stacktrace=stacktrace, container=container, platforms=platforms))
for exc in get_path(data, 'exception', 'values', filter=True, default=()):
_report_stack(exc.get('stacktrace'), exc)
_report_stack(data.get('stacktrace'), None)
for thread in get_path(data, 'threads', 'values', filter=True, default=()):
_report_stack(thread.get('stacktrace'), thread)
if include_raw:
for info in rv[:]:
if info.container is not None:
_report_stack(info.container.get('raw_stacktrace'), info.container)
return rv
开发者ID:getsentry,项目名称:sentry,代码行数:32,代码来源:processing.py
示例5: get_thread_apple_string
def get_thread_apple_string(self, thread_info):
rv = []
stacktrace = get_path(thread_info, 'stacktrace')
if stacktrace is None:
return None
if stacktrace:
frames = get_path(stacktrace, 'frames', filter=True)
if frames:
for i, frame in enumerate(reversed(frames)):
frame_string = self._convert_frame_to_apple_string(
frame=frame,
next=frames[len(frames) - i -
2] if i < len(frames) - 1 else None,
number=i
)
if frame_string is not None:
rv.append(frame_string)
if len(rv) == 0:
return None # No frames in thread, so we remove thread
is_exception = bool(thread_info.get('mechanism'))
thread_id = thread_info.get('id') or thread_info.get('thread_id') or '0'
thread_name = thread_info.get('name')
thread_name_string = ' name: %s' % (thread_name) if thread_name else ''
thread_crashed = thread_info.get('crashed') or is_exception
thread_crashed_thread = ' Crashed:' if thread_crashed else ''
thread_string = 'Thread %s%s%s\n' % (
thread_id, thread_name_string, thread_crashed_thread
)
return thread_string + '\n'.join(rv)
开发者ID:Kayle009,项目名称:sentry,代码行数:32,代码来源:applecrashreport.py
示例6: _get_frame_paths
def _get_frame_paths(event):
data = event.data
frames = get_path(data, 'stacktrace', 'frames', filter=True)
if frames:
return frames
return get_path(data, 'exception', 'values', 0, 'stacktrace', 'frames', filter=True) or []
开发者ID:yaoqi,项目名称:sentry,代码行数:7,代码来源:committers.py
示例7: real_message
def real_message(self):
# XXX(mitsuhiko): this is a transitional attribute that should be
# removed. `message` will be renamed to `search_message` and this
# will become `message`.
return get_path(self.data, 'logentry', 'formatted') \
or get_path(self.data, 'logentry', 'message') \
or ''
开发者ID:getsentry,项目名称:sentry,代码行数:7,代码来源:event.py
示例8: apply
def apply(self, data):
# TODO(dcramer): move this into each interface
if data.get('stacktrace'):
self.filter_stacktrace(data['stacktrace'])
for exc in get_path(data, 'exception', 'values', filter=True) or ():
if exc.get('stacktrace'):
self.filter_stacktrace(exc['stacktrace'])
for exc in get_path(data, 'threads', 'values', filter=True) or ():
if exc.get('stacktrace'):
self.filter_stacktrace(exc['stacktrace'])
for crumb in get_path(data, 'breadcrumbs', 'values', filter=True) or ():
self.filter_crumb(crumb)
if data.get('request'):
self.filter_http(data['request'])
if data.get('user'):
self.filter_user(data['user'])
if data.get('csp'):
self.filter_csp(data['csp'])
if data.get('extra'):
data['extra'] = varmap(self.sanitize, data['extra'])
if data.get('contexts'):
for key, value in six.iteritems(data['contexts']):
if value:
data['contexts'][key] = varmap(self.sanitize, value)
开发者ID:yaoqi,项目名称:sentry,代码行数:32,代码来源:data_scrubber.py
示例9: find_best_instruction
def find_best_instruction(self, processable_frame):
"""Given a frame, stacktrace info and frame index this returns the
interpolated instruction address we then use for symbolication later.
"""
if self.arch is None:
return parse_addr(processable_frame['instruction_addr'])
crashing_frame = False
signal = None
ip_reg = None
# We only need to provide meta information for frame zero
if processable_frame.idx == 0:
# The signal is useful information for symbolic in some situations
# to disambiugate the first frame. If we can get this information
# from the mechanism we want to pass it onwards.
exceptions = get_path(self.data, 'exception', 'values', filter=True)
signal = get_path(exceptions, 0, 'mechanism', 'meta', 'signal', 'number')
if signal is not None:
signal = int(signal)
registers = processable_frame.stacktrace_info.stacktrace.get('registers')
if registers:
ip_reg_name = arch_get_ip_reg_name(self.arch)
if ip_reg_name:
ip_reg = registers.get(ip_reg_name)
crashing_frame = True
return find_best_instruction(
processable_frame['instruction_addr'],
arch=self.arch,
crashing_frame=crashing_frame,
signal=signal,
ip_reg=ip_reg
)
开发者ID:Kayle009,项目名称:sentry,代码行数:35,代码来源:plugin.py
示例10: _get_meta_header
def _get_meta_header(self):
return 'OS Version: %s %s (%s)\nReport Version: %s' % (
get_path(self.context, 'os', 'name'),
get_path(self.context, 'os', 'version'),
get_path(self.context, 'os', 'build'),
REPORT_VERSION,
)
开发者ID:Kayle009,项目名称:sentry,代码行数:7,代码来源:applecrashreport.py
示例11: get_sdk_from_event
def get_sdk_from_event(event):
sdk_info = get_path(event, 'debug_meta', 'sdk_info')
if sdk_info:
return sdk_info
os = get_path(event, 'contexts', 'os')
if os and os.get('type') == 'os':
return get_sdk_from_os(os)
开发者ID:Kayle009,项目名称:sentry,代码行数:8,代码来源:utils.py
示例12: get_legacy_message
def get_legacy_message(self):
# TODO(mitsuhiko): remove this code once it's unused. It's still
# being used by plugin code and once the message rename is through
# plugins should instead swithc to the actual message attribute or
# this method could return what currently is real_message.
return get_path(self.data, 'logentry', 'formatted') \
or get_path(self.data, 'logentry', 'message') \
or self.message
开发者ID:getsentry,项目名称:sentry,代码行数:8,代码来源:event.py
示例13: 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
示例14: _report_stack
def _report_stack(stacktrace, container):
if not stacktrace or not get_path(stacktrace, 'frames', filter=True):
return
platforms = set(
frame.get('platform') or data.get('platform')
for frame in get_path(stacktrace, 'frames', filter=True, default=())
)
rv.append(StacktraceInfo(stacktrace=stacktrace, container=container, platforms=platforms))
开发者ID:getsentry,项目名称:sentry,代码行数:9,代码来源:processing.py
示例15: has_sourcemap
def has_sourcemap(event):
if event.platform not in ('javascript', 'node'):
return False
for exception in get_path(event.data, 'exception', 'values', filter=True, default=()):
for frame in get_path(exception, 'stacktrace', 'frames', filter=True, default=()):
if 'sourcemap' in (frame.get('data') or ()):
return True
return False
开发者ID:Kayle009,项目名称:sentry,代码行数:10,代码来源:javascript.py
示例16: ip_address
def ip_address(self):
ip_address = get_path(self.data, 'user', 'ip_address')
if ip_address:
return ip_address
remote_addr = get_path(self.data, 'request', 'env', 'REMOTE_ADDR')
if remote_addr:
return remote_addr
return None
开发者ID:getsentry,项目名称:sentry,代码行数:10,代码来源:event.py
示例17: get
def get(self, request, project, event_id):
"""
Retrieve an Apple Crash Report from an event
`````````````````````````````````````````````
This endpoint returns the an apple crash report for a specific event.
The event ID is either the event as it appears in the Sentry database
or the event ID that is reported by the client upon submission.
This works only if the event.platform == cocoa
"""
use_snuba = options.get('snuba.events-queries.enabled')
event_cls = event_cls = SnubaEvent if use_snuba else Event
event = event_cls.objects.from_event_id(event_id, project_id=project.id)
if event is None:
raise ResourceDoesNotExist
Event.objects.bind_nodes([event], 'data')
if event.platform not in ('cocoa', 'native'):
return HttpResponse(
{
'message': 'Only cocoa events can return an apple crash report',
}, status=403
)
symbolicated = (request.GET.get('minified') not in ('1', 'true'))
apple_crash_report_string = six.text_type(
AppleCrashReport(
threads=get_path(event.data, 'threads', 'values', filter=True),
context=event.data.get('contexts'),
debug_images=get_path(event.data, 'debug_meta', 'images', filter=True),
exceptions=get_path(event.data, 'exception', 'values', filter=True),
symbolicated=symbolicated,
)
)
response = HttpResponse(apple_crash_report_string,
content_type='text/plain')
if request.GET.get('download') is not None:
filename = u"{}{}.crash".format(
event.event_id, symbolicated and '-symbolicated' or '')
response = StreamingHttpResponse(
apple_crash_report_string,
content_type='text/plain',
)
response['Content-Length'] = len(apple_crash_report_string)
response['Content-Disposition'] = 'attachment; filename="%s"' % filename
return response
开发者ID:getsentry,项目名称:sentry,代码行数:54,代码来源:event_apple_crash_report.py
示例18: get_metadata
def get_metadata(self):
message = strip(get_path(self.data, 'logentry', 'formatted') or
get_path(self.data, 'logentry', 'message'))
if message:
title = truncatechars(message.splitlines()[0], 100)
else:
title = '<unlabeled event>'
return {
'title': title,
}
开发者ID:Kayle009,项目名称:sentry,代码行数:12,代码来源:base.py
示例19: merge_symbolicator_minidump_response
def merge_symbolicator_minidump_response(data, response):
sdk_info = get_sdk_from_event(data)
# TODO(markus): Add OS context here when `merge_process_state_event` is no
# longer called for symbolicator projects
images = []
set_path(data, 'debug_meta', 'images', value=images)
for complete_image in response['modules']:
image = {}
merge_symbolicator_image(
image, complete_image, sdk_info,
lambda e: handle_symbolication_failed(e, data=data)
)
images.append(image)
data_threads = []
data['threads'] = {'values': data_threads}
data_exception = get_path(data, 'exception', 'values', 0)
for complete_stacktrace in response['stacktraces']:
is_requesting = complete_stacktrace.get('is_requesting')
thread_id = complete_stacktrace.get('thread_id')
data_thread = {
'id': thread_id,
'crashed': is_requesting,
}
data_threads.append(data_thread)
if is_requesting:
data_stacktrace = get_path(data_exception, 'stacktrace')
assert isinstance(data_stacktrace, dict), data_stacktrace
# Make exemption specifically for unreal portable callstacks
# TODO(markus): Allow overriding stacktrace more generically
# (without looking into unreal context) once we no longer parse
# minidump in the endpoint (right now we can't distinguish that
# from user json).
if data_stacktrace['frames'] and is_unreal_exception_stacktrace(data):
continue
del data_stacktrace['frames'][:]
else:
data_thread['stacktrace'] = data_stacktrace = {'frames': []}
if complete_stacktrace.get('registers'):
data_stacktrace['registers'] = complete_stacktrace['registers']
for complete_frame in reversed(complete_stacktrace['frames']):
new_frame = {}
merge_symbolicated_frame(new_frame, complete_frame)
data_stacktrace['frames'].append(new_frame)
开发者ID:getsentry,项目名称:sentry,代码行数:53,代码来源:minidump.py
示例20: ensure_does_not_have_ip
def ensure_does_not_have_ip(self, data):
env = get_path(data, 'request', 'env')
if env:
env.pop('REMOTE_ADDR', None)
user = get_path(data, 'user')
if user:
user.pop('ip_address', None)
sdk = get_path(data, 'sdk')
if sdk:
sdk.pop('client_ip', None)
开发者ID:getsentry,项目名称:sentry,代码行数:12,代码来源:coreapi.py
注:本文中的sentry.utils.safe.get_path函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论