本文整理汇总了Python中sentry.models.ProjectKey类的典型用法代码示例。如果您正苦于以下问题:Python ProjectKey类的具体用法?Python ProjectKey怎么用?Python ProjectKey使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ProjectKey类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: forwards
def forwards(self, orm):
from sentry.models import ProjectKey
for project in orm['sentry.Project'].objects.all():
if orm['sentry.ProjectKey'].objects.filter(project=project, user=None).exists():
continue
orm['sentry.ProjectKey'].objects.create(
project=project,
public_key=ProjectKey.generate_api_key(),
secret_key=ProjectKey.generate_api_key(),
)
开发者ID:755,项目名称:sentry,代码行数:12,代码来源:0049_create_default_project_keys.py
示例2: project_key
def project_key(self):
from sentry.models import ProjectKey
if not settings.SENTRY_PROJECT:
return None
key = None
try:
if settings.SENTRY_PROJECT_KEY is not None:
key = ProjectKey.objects.get(
id=settings.SENTRY_PROJECT_KEY,
project=settings.SENTRY_PROJECT,
)
else:
key = ProjectKey.get_default(settings.SENTRY_PROJECT)
except Exception as exc:
# if the relation fails to query or is missing completely, lets handle
# it gracefully
self.error_logger.warn('internal-error.unable-to-fetch-project', extra={
'project_id': settings.SENTRY_PROJECT,
'project_key': settings.SENTRY_PROJECT_KEY,
'error_message': six.text_type(exc),
})
if key is None:
self.error_logger.warn('internal-error.no-project-available', extra={
'project_id': settings.SENTRY_PROJECT,
'project_key': settings.SENTRY_PROJECT_KEY,
})
return key
开发者ID:mjumbewu,项目名称:sentry,代码行数:29,代码来源:raven.py
示例3: project_key_from_auth
def project_key_from_auth(self, auth):
if not auth.public_key:
raise APIUnauthorized('Invalid api key')
# Make sure the key even looks valid first, since it's
# possible to get some garbage input here causing further
# issues trying to query it from cache or the database.
if not ProjectKey.looks_like_api_key(auth.public_key):
raise APIUnauthorized('Invalid api key')
try:
pk = ProjectKey.objects.get_from_cache(public_key=auth.public_key)
except ProjectKey.DoesNotExist:
raise APIUnauthorized('Invalid api key')
# a secret key may not be present which will be validated elsewhere
if not constant_time_compare(pk.secret_key, auth.secret_key or pk.secret_key):
raise APIUnauthorized('Invalid api key')
if not pk.is_active:
raise APIUnauthorized('API key is disabled')
if not pk.roles.store:
raise APIUnauthorized('Key does not allow event storage access')
return pk
开发者ID:duanshuaimin,项目名称:sentry,代码行数:26,代码来源:coreapi.py
示例4: _get_project_key
def _get_project_key(self, request):
dsn = request.GET.get('dsn')
try:
key = ProjectKey.from_dsn(dsn)
except ProjectKey.DoesNotExist:
return
return key
开发者ID:280185386,项目名称:sentry,代码行数:8,代码来源:error_page_embed.py
示例5: _get_project_key
def _get_project_key(self, request):
try:
dsn = request.GET['dsn']
except KeyError:
return
try:
key = ProjectKey.from_dsn(dsn)
except ProjectKey.DoesNotExist:
return
return key
开发者ID:Andy-hpliu,项目名称:sentry,代码行数:12,代码来源:error_page_embed.py
示例6: get
def get(self, request, project):
data = options.get('sentry:docs')
project_key = ProjectKey.get_default(project)
context = {
'platforms': data['platforms'],
}
if project_key:
context['dsn'] = project_key.dsn_private
context['dsnPublic'] = project_key.dsn_public
return Response(context)
开发者ID:AyrtonRicardo,项目名称:sentry,代码行数:12,代码来源:project_docs.py
示例7: send
def send(self, **kwargs):
# Report the issue to an upstream Sentry if active
# NOTE: we don't want to check self.is_enabled() like normal, since
# is_enabled behavior is overridden in this class. We explicitly
# want to check if the remote is active.
if self.remote.is_active():
from sentry import options
# Append some extra tags that are useful for remote reporting
super_kwargs = copy.deepcopy(kwargs)
super_kwargs['tags']['install-id'] = options.get('sentry:install-id')
super(SentryInternalClient, self).send(**super_kwargs)
if not is_current_event_safe():
return
# These imports all need to be internal to this function as this class
# is set up by django while still parsing LOGGING settings and we
# cannot import this stuff until settings are finalized.
from sentry.models import ProjectKey
from sentry.web.api import StoreView
from django.test import RequestFactory
key = None
if settings.SENTRY_PROJECT_KEY is not None:
key = ProjectKey.objects.filter(
id=settings.SENTRY_PROJECT_KEY,
project=settings.SENTRY_PROJECT).first()
if key is None:
key = ProjectKey.get_default(settings.SENTRY_PROJECT)
if key is None:
return
client_string = 'raven-python/%s' % (raven.VERSION,)
headers = {
'HTTP_X_SENTRY_AUTH': get_auth_header(
protocol=self.protocol_version,
timestamp=time.time(),
client=client_string,
api_key=key.public_key,
api_secret=key.secret_key,
),
'HTTP_CONTENT_ENCODING': self.get_content_encoding(),
}
self.request_factory = self.request_factory or RequestFactory()
request = self.request_factory.post(
'/api/store',
data=self.encode(kwargs),
content_type='application/octet-stream',
**headers
)
StoreView.as_view()(
request,
project_id=six.text_type(settings.SENTRY_PROJECT),
)
开发者ID:binlee1990,项目名称:sentry,代码行数:53,代码来源:raven.py
示例8: get
def get(self, request, project, platform):
data = load_doc(platform)
if not data:
raise ResourceDoesNotExist
project_key = ProjectKey.get_default(project)
return Response({
'id': data['id'],
'name': data['name'],
'html': replace_keys(data['html'], project_key),
'link': data['link'],
})
开发者ID:ForkRepo,项目名称:sentry,代码行数:13,代码来源:project_docs_platform.py
示例9: authenticate_credentials
def authenticate_credentials(self, token):
try:
key = ProjectKey.from_dsn(token)
except ProjectKey.DoesNotExist:
raise AuthenticationFailed('Invalid token')
if not key.is_active:
raise AuthenticationFailed('Invalid token')
with configure_scope() as scope:
scope.set_tag("api_token_type", self.token_name)
scope.set_tag("api_project_key", key.id)
return (AnonymousUser(), key)
开发者ID:Kayle009,项目名称:sentry,代码行数:14,代码来源:authentication.py
示例10: get
def get(self, request, project):
data = load_doc('_platforms')
if data is None:
raise RuntimeError('Docs not built')
project_key = ProjectKey.get_default(project)
context = {
'platforms': data['platforms'],
}
if project_key:
context['dsn'] = project_key.dsn_private
context['dsnPublic'] = project_key.dsn_public
return Response(context)
开发者ID:280185386,项目名称:sentry,代码行数:14,代码来源:project_docs.py
示例11: test_get_dsn_with_port
def test_get_dsn_with_port(self):
key = ProjectKey(project_id=1, public_key='public', secret_key='secret')
with self.Settings(SENTRY_URL_PREFIX='http://example.com:81'):
self.assertEquals(key.get_dsn(), 'http://public:[email protected]:81/1')
开发者ID:Crowdbooster,项目名称:sentry,代码行数:4,代码来源:tests.py
示例12: save
def save(self, *args, **kwargs):
if not self.public_key:
self.public_key = ProjectKey.generate_api_key()
if not self.secret_key:
self.secret_key = ProjectKey.generate_api_key()
super(ProjectKey, self).save(*args, **kwargs)
开发者ID:clawplach,项目名称:sentry,代码行数:6,代码来源:models.py
示例13: test_get_dsn_with_endpoint_setting
def test_get_dsn_with_endpoint_setting(self):
key = ProjectKey(project_id=1, public_key='public', secret_key='secret')
with self.settings(SENTRY_ENDPOINT='http://endpoint.com'):
self.assertEquals(key.get_dsn(), 'http://public:[email protected]/1')
开发者ID:BlueMoebius,项目名称:sentry,代码行数:4,代码来源:tests.py
示例14: test_get_dsn_with_port
def test_get_dsn_with_port(self):
key = ProjectKey(project_id=1, public_key='public', secret_key='secret')
with self.options({'system.url-prefix': 'http://example.com:81'}):
self.assertEquals(key.get_dsn(), 'http://public:[email protected]:81/1')
开发者ID:alexandrul,项目名称:sentry,代码行数:4,代码来源:tests.py
注:本文中的sentry.models.ProjectKey类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论