本文整理汇总了Python中sentry.coreapi.validate_data函数的典型用法代码示例。如果您正苦于以下问题:Python validate_data函数的具体用法?Python validate_data怎么用?Python validate_data使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了validate_data函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: handle_sentry
def handle_sentry(data, address):
from sentry.exceptions import InvalidData
from sentry.coreapi import project_from_auth_vars, decode_and_decompress_data, \
safely_load_json_string, validate_data, insert_data_to_database, APIError
from sentry.utils.auth import parse_auth_header
try:
try:
auth_header, data = data.split('\n\n', 1)
except ValueError:
raise APIError('missing auth header')
auth_vars = parse_auth_header(auth_header)
project = project_from_auth_vars(auth_vars, data)
client = auth_vars.get('sentry_client')
if not data.startswith('{'):
data = decode_and_decompress_data(data)
data = safely_load_json_string(data)
try:
validate_data(project, data, client)
except InvalidData, e:
raise APIError(unicode(e))
return insert_data_to_database(data)
开发者ID:eventbrite,项目名称:django-sentry,代码行数:27,代码来源:udp.py
示例2: test_invalid_interface_name
def test_invalid_interface_name(self):
with self.assertRaises(InvalidInterface):
validate_data(self.project, {
'project': self.project.id,
'message': 'foo',
'foo.baz': 'bar',
})
开发者ID:Supy,项目名称:sentry,代码行数:7,代码来源:tests.py
示例3: test_invalid_interface_args
def test_invalid_interface_args(self):
with self.assertRaises(InvalidData):
validate_data(self.project, {
'project': self.project.id,
'message': 'foo',
'tests.manager.tests.DummyInterface': {'foo': 'bar'}
})
开发者ID:Supy,项目名称:sentry,代码行数:7,代码来源:tests.py
示例4: test_invalid_interface_import_path
def test_invalid_interface_import_path(self):
with self.assertRaises(InvalidInterface):
validate_data(self.project, {
'project': self.project.id,
'message': 'foo',
'sentry.interfaces.Exception2': 'bar',
})
开发者ID:Supy,项目名称:sentry,代码行数:7,代码来源:tests.py
示例5: handle
def handle(self, data, address):
from sentry.utils.auth import parse_auth_header
from sentry.coreapi import (project_from_auth_vars, decode_and_decompress_data, safely_load_json_string,
validate_data, insert_data_to_database, APIError)
try:
try:
auth_header, data = data.split("\n\n", 1)
except ValueError:
raise APIError("missing auth header")
project = project_from_auth_vars(parse_auth_header(auth_header), data)
if not data.startswith('{'):
data = decode_and_decompress_data(data)
data = safely_load_json_string(data)
try:
validate_data(project, data)
except InvalidTimestamp:
# Log the error, remove the timestamp, and revalidate
logger.error('Client %r passed an invalid value for timestamp %r' % (
data['timestamp'],
client or '<unknown client>',
))
del data['timestamp']
validate_data(project, data)
return insert_data_to_database(data)
except APIError, error:
logger.error('bad message from %s: %s' % (address, error.msg))
return error
开发者ID:lboaretto,项目名称:sentry,代码行数:30,代码来源:udp.py
示例6: store
def store(request):
try:
auth_vars = extract_auth_vars(request)
data = request.raw_post_data
if auth_vars:
server_version = auth_vars.get('sentry_version', '1.0')
else:
server_version = request.GET.get('version', '1.0')
if server_version not in ('1.0', '2.0'):
raise APIError('Client/server version mismatch. Unsupported version: %r' % server_version)
if auth_vars:
project = project_from_auth_vars(auth_vars, data)
elif request.GET.get('api_key') and request.GET.get('project_id') and request.is_secure():
# ssl requests dont have to have signature verification
project = project_from_api_key_and_id(request.GET['api_key'], request.GET['project_id'])
elif request.GET.get('project_id') and request.user.is_authenticated():
# authenticated users are simply trusted to provide the right id
project = project_from_id(request)
else:
raise APIUnauthorized()
if not data.startswith('{'):
data = decode_and_decompress_data(data)
data = safely_load_json_string(data)
validate_data(project, data)
insert_data_to_database(data)
except APIError, error:
return HttpResponse(error.msg, status=error.http_status)
开发者ID:twoolie,项目名称:sentry,代码行数:33,代码来源:api.py
示例7: post
def post(self, request, project, auth, **kwargs):
data = request.raw_post_data
if not data.startswith('{'):
data = decode_and_decompress_data(data)
data = safely_load_json_string(data)
try:
validate_data(project, data, auth.client)
except InvalidData, e:
raise APIError(u'Invalid data: %s (%s)' % (unicode(e), type(e)))
开发者ID:fbentz,项目名称:sentry,代码行数:11,代码来源:api.py
示例8: process
def process(self, request, project, auth, data, **kwargs):
result = plugins.first('has_perm', request.user, 'create_event', project)
if result is False:
raise APIForbidden('Creation of this event was blocked')
if not data.startswith('{'):
data = decode_and_decompress_data(data)
data = safely_load_json_string(data)
try:
validate_data(project, data, auth.client)
except InvalidData, e:
raise APIError(u'Invalid data: %s (%s)' % (unicode(e), type(e)))
开发者ID:TracyWebTech,项目名称:sentry,代码行数:13,代码来源:api.py
示例9: process
def process(self, request, project, auth, data, **kwargs):
event_received.send_robust(ip=request.META['REMOTE_ADDR'], sender=type(self))
# TODO: improve this API (e.g. make RateLimit act on __ne__)
rate_limit = safe_execute(app.quotas.is_rate_limited, project=project)
if isinstance(rate_limit, bool):
rate_limit = RateLimit(is_limited=rate_limit, retry_after=None)
if rate_limit is not None and rate_limit.is_limited:
raise APIRateLimited(rate_limit.retry_after)
result = plugins.first('has_perm', request.user, 'create_event', project)
if result is False:
raise APIForbidden('Creation of this event was blocked')
content_encoding = request.META.get('HTTP_CONTENT_ENCODING', '')
if content_encoding == 'gzip':
data = decompress_gzip(data)
elif content_encoding == 'deflate':
data = decompress_deflate(data)
elif not data.startswith('{'):
data = decode_and_decompress_data(data)
data = safely_load_json_string(data)
try:
# mutates data
validate_data(project, data, auth.client)
except InvalidData as e:
raise APIError(u'Invalid data: %s (%s)' % (six.text_type(e), type(e)))
# mutates data
manager = EventManager(data)
data = manager.normalize()
# insert IP address if not available
if auth.is_public:
ensure_has_ip(data, request.META['REMOTE_ADDR'])
event_id = data['event_id']
# We filter data immediately before it ever gets into the queue
inst = SensitiveDataFilter()
inst.apply(data)
# mutates data (strips a lot of context if not queued)
insert_data_to_database(data)
logger.debug('New event from project %s/%s (id=%s)', project.team.slug, project.slug, event_id)
return event_id
开发者ID:CrazyLionHeart,项目名称:sentry,代码行数:51,代码来源:api.py
示例10: process
def process(self, request, project, auth, data, **kwargs):
event_received.send_robust(ip=request.META['REMOTE_ADDR'], sender=type(self))
rate_limits = [safe_execute(app.quotas.is_rate_limited, project=project)]
for plugin in plugins.all():
rate_limit = safe_execute(plugin.is_rate_limited, project=project)
# We must handle the case of plugins not returning new RateLimit objects
if isinstance(rate_limit, bool):
rate_limit = RateLimit(is_limited=rate_limit, retry_after=None)
rate_limits.append(rate_limit)
if any(limit.is_limited for limit in rate_limits):
raise APIRateLimited(max(limit.retry_after for limit in rate_limits))
result = plugins.first('has_perm', request.user, 'create_event', project)
if result is False:
raise APIForbidden('Creation of this event was blocked')
content_encoding = request.META.get('HTTP_CONTENT_ENCODING', '')
if content_encoding == 'gzip':
data = decompress_gzip(data)
elif content_encoding == 'deflate':
data = decompress_deflate(data)
elif not data.startswith('{'):
data = decode_and_decompress_data(data)
data = safely_load_json_string(data)
try:
# mutates data
validate_data(project, data, auth.client)
except InvalidData as e:
raise APIError(u'Invalid data: %s (%s)' % (unicode(e), type(e)))
# mutates data
Group.objects.normalize_event_data(data)
# insert IP address if not available
if auth.is_public:
ensure_has_ip(data, request.META['REMOTE_ADDR'])
event_id = data['event_id']
# mutates data (strips a lot of context if not queued)
insert_data_to_database(data)
logger.debug('New event from project %s/%s (id=%s)', project.team.slug, project.slug, event_id)
return event_id
开发者ID:aramirez92,项目名称:sentry,代码行数:49,代码来源:api.py
示例11: test_log_level_as_string
def test_log_level_as_string(self):
data = validate_data(self.project, {
'project': self.project.id,
'message': 'foo',
'level': 'error',
})
self.assertEquals(data['level'], 40)
开发者ID:Crowdbooster,项目名称:sentry,代码行数:7,代码来源:tests.py
示例12: test_unknown_attribute
def test_unknown_attribute(self):
data = validate_data(self.project, {
'project': self.project.slug,
'message': 'foo',
'foo': 'bar',
})
self.assertFalse('foo' in data)
开发者ID:fbentz,项目名称:sentry,代码行数:7,代码来源:tests.py
示例13: process
def process(self, request, project, auth, data, **kwargs):
event_received.send(ip=request.META["REMOTE_ADDR"], sender=type(self))
is_rate_limited = safe_execute(app.quotas.is_rate_limited, project=project)
for plugin in plugins.all():
if safe_execute(plugin.is_rate_limited, project=project):
is_rate_limited = True
if is_rate_limited:
raise APIRateLimited
result = plugins.first("has_perm", request.user, "create_event", project)
if result is False:
raise APIForbidden("Creation of this event was blocked")
content_encoding = request.META.get("HTTP_CONTENT_ENCODING", "")
if content_encoding == "gzip":
data = decompress_gzip(data)
elif content_encoding == "deflate":
data = decompress_deflate(data)
elif not data.startswith("{"):
data = decode_and_decompress_data(data)
data = safely_load_json_string(data)
try:
# mutates data
validate_data(project, data, auth.client)
except InvalidData as e:
raise APIError(u"Invalid data: %s (%s)" % (unicode(e), type(e)))
# mutates data
Group.objects.normalize_event_data(data)
# insert IP address if not available
if auth.is_public:
ensure_has_ip(data, request.META["REMOTE_ADDR"])
event_id = data["event_id"]
# mutates data (strips a lot of context if not queued)
insert_data_to_database(data)
logger.debug("New event from project %s/%s (id=%s)", project.team.slug, project.slug, event_id)
return event_id
开发者ID:jonaskje,项目名称:sentry,代码行数:46,代码来源:api.py
示例14: handle_sentry
def handle_sentry(data, address):
from sentry.coreapi import (
project_from_auth_vars,
decode_and_decompress_data,
safely_load_json_string,
validate_data,
insert_data_to_database,
APIError,
APIForbidden,
)
from sentry.models import Group
from sentry.exceptions import InvalidData
from sentry.plugins import plugins
from sentry.utils.auth import parse_auth_header
try:
try:
auth_header, data = data.split("\n\n", 1)
except ValueError:
raise APIError("missing auth header")
try:
auth_vars = parse_auth_header(auth_header)
except (ValueError, IndexError):
raise APIError("invalid auth header")
project, user = project_from_auth_vars(auth_vars)
result = plugins.first("has_perm", user, "create_event", project)
if result is False:
raise APIForbidden("Creation of this event was blocked")
client = auth_vars.get("sentry_client")
if not data.startswith("{"):
data = decode_and_decompress_data(data)
data = safely_load_json_string(data)
try:
validate_data(project, data, client)
except InvalidData, e:
raise APIError(u"Invalid data: %s (%s)" % (unicode(e), type(e)))
Group.objects.normalize_event_data(data)
return insert_data_to_database(data)
开发者ID:beyondtime,项目名称:sentry,代码行数:46,代码来源:udp.py
示例15: process
def process(self, request, project, auth, data, **kwargs):
for plugin in plugins.all():
if safe_execute(plugin.is_rate_limited, project=project):
return HttpResponse('Creation of this event was denied due to rate limiting.', content_type='text/plain', status=405)
result = plugins.first('has_perm', request.user, 'create_event', project)
if result is False:
raise APIForbidden('Creation of this event was blocked')
if not data.startswith('{'):
data = decode_and_decompress_data(data)
data = safely_load_json_string(data)
try:
# mutates data
validate_data(project, data, auth.client)
except InvalidData, e:
raise APIError(u'Invalid data: %s (%s)' % (unicode(e), type(e)))
开发者ID:anujsrc,项目名称:sentry,代码行数:18,代码来源:api.py
示例16: test_does_expand_list
def test_does_expand_list(self):
data = validate_data(self.project, {
'message': 'foo',
'exception': [{
'type': 'ValueError',
'value': 'hello world',
'module': 'foo.bar',
}]
})
assert 'sentry.interfaces.Exception' in data
开发者ID:Superdense,项目名称:sentry,代码行数:10,代码来源:tests.py
示例17: test_an_alias_maps_correctly
def test_an_alias_maps_correctly(self, import_string):
alias, full_path = INTERFACE_ALIASES.items()[0]
result = validate_data(self.project, {"project": self.project.id, "message": "foo", alias: {"foo": "bar"}})
import_string.assert_called_once_with(full_path)
interface = import_string.return_value
interface.assert_called_once_with(foo="bar")
assert alias not in result
assert full_path in result
assert result[full_path] == interface.return_value.serialize.return_value
开发者ID:vartagg,项目名称:sentry,代码行数:10,代码来源:tests.py
示例18: process
def process(self, request, project, auth, data, **kwargs):
if safe_execute(app.quotas.is_rate_limited, project=project):
raise APIRateLimited
for plugin in plugins.all():
if safe_execute(plugin.is_rate_limited, project=project):
raise APIRateLimited
result = plugins.first('has_perm', request.user, 'create_event', project)
if result is False:
raise APIForbidden('Creation of this event was blocked')
if not data.startswith('{'):
data = decode_and_decompress_data(data)
data = safely_load_json_string(data)
try:
# mutates data
validate_data(project, data, auth.client)
except InvalidData, e:
raise APIError(u'Invalid data: %s (%s)' % (unicode(e), type(e)))
开发者ID:BlaShadow,项目名称:sentry,代码行数:20,代码来源:api.py
示例19: handle
def handle(self, data, address):
from sentry.utils.auth import parse_auth_header
from sentry.coreapi import (project_from_auth_vars, decode_and_decompress_data, safely_load_json_string,
validate_data, insert_data_to_database, APIError)
try:
try:
auth_header, data = data.split("\n\n", 1)
except ValueError:
raise APIError("missing auth header")
project = project_from_auth_vars(parse_auth_header(auth_header), data)
if not data.startswith('{'):
data = decode_and_decompress_data(data)
data = safely_load_json_string(data)
validate_data(project, data)
return insert_data_to_database(data)
except APIError, error:
logger.error('bad message from %s: %s' % (address, error.msg))
return error
开发者ID:twoolie,项目名称:sentry,代码行数:21,代码来源:udp.py
示例20: process
def process(self, request, project, auth, data, **kwargs):
event_received.send(ip=request.META['REMOTE_ADDR'], sender=type(self))
is_rate_limited = safe_execute(app.quotas.is_rate_limited, project=project)
for plugin in plugins.all():
if safe_execute(plugin.is_rate_limited, project=project):
is_rate_limited = True
if is_rate_limited:
raise APIRateLimited
result = plugins.first('has_perm', request.user, 'create_event', project)
if result is False:
raise APIForbidden('Creation of this event was blocked')
if not data.startswith('{'):
data = decode_and_decompress_data(data)
data = safely_load_json_string(data)
try:
# mutates data
validate_data(project, data, auth.client)
except InvalidData as e:
raise APIError(u'Invalid data: %s (%s)' % (unicode(e), type(e)))
# mutates data
Group.objects.normalize_event_data(data)
# insert IP address if not available
if auth.is_public:
ensure_has_ip(data, request.META['REMOTE_ADDR'])
event_id = data['event_id']
# mutates data (strips a lot of context if not queued)
insert_data_to_database(data)
logger.debug('New event from project %s/%s (id=%s)', project.team.slug, project.slug, event_id)
return event_id
开发者ID:CaseCommonsDevOps,项目名称:sentry,代码行数:40,代码来源:api.py
注:本文中的sentry.coreapi.validate_data函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论