本文整理汇总了Python中sentry.models.ProjectKey.get_default方法的典型用法代码示例。如果您正苦于以下问题:Python ProjectKey.get_default方法的具体用法?Python ProjectKey.get_default怎么用?Python ProjectKey.get_default使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sentry.models.ProjectKey
的用法示例。
在下文中一共展示了ProjectKey.get_default方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: project_key
# 需要导入模块: from sentry.models import ProjectKey [as 别名]
# 或者: from sentry.models.ProjectKey import get_default [as 别名]
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
示例2: get
# 需要导入模块: from sentry.models import ProjectKey [as 别名]
# 或者: from sentry.models.ProjectKey import get_default [as 别名]
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)
示例3: send
# 需要导入模块: from sentry.models import ProjectKey [as 别名]
# 或者: from sentry.models.ProjectKey import get_default [as 别名]
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),
)
示例4: get
# 需要导入模块: from sentry.models import ProjectKey [as 别名]
# 或者: from sentry.models.ProjectKey import get_default [as 别名]
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'],
})
示例5: get
# 需要导入模块: from sentry.models import ProjectKey [as 别名]
# 或者: from sentry.models.ProjectKey import get_default [as 别名]
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)