本文整理汇总了Python中sentry.plugins.plugins.get函数的典型用法代码示例。如果您正苦于以下问题:Python get函数的具体用法?Python get怎么用?Python get使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_simple
def test_simple(self, test_configuration):
project = self.create_project()
self.login_as(user=self.user)
plugins.get('webhooks').disable(project)
url = reverse(
'sentry-api-0-project-plugin-details',
kwargs={
'organization_slug': project.organization.slug,
'project_slug': project.slug,
'plugin_id': 'webhooks',
}
)
response = self.client.post(url)
assert response.status_code == 201, (response.status_code, response.content)
assert ProjectOption.objects.get(
key='webhooks:enabled',
project=project,
).value is True
# Testing the Plugin
response = self.client.post(url, {'test': True})
test_configuration.assert_called_once_with(project)
assert response.status_code == 200, (response.status_code, response.content)
示例2: test_simple
def test_simple(self):
project = self.create_project()
self.login_as(user=self.user)
plugins.get('webhooks').enable(project)
url = reverse(
'sentry-api-0-project-plugin-details',
kwargs={
'organization_slug': project.organization.slug,
'project_slug': project.slug,
'plugin_id': 'webhooks',
}
)
audit = AuditLogEntry.objects.filter(target_object=project.id)
assert not audit
response = self.client.delete(url)
audit = AuditLogEntry.objects.get(target_object=project.id)
assert audit.event == 112
assert response.status_code == 204, (response.status_code, response.content)
assert ProjectOption.objects.get(
key='webhooks:enabled',
project=project,
).value is False
示例3: setUp
def setUp(self):
self.projectA = self.create_project()
self.projectB = self.create_project(organization=self.projectA.organization)
plugins.get('webhooks').enable(self.projectA)
plugins.get('mail').enable(self.projectB)
self.login_as(user=self.user)
示例4: configure_project_plugin
def configure_project_plugin(request, organization, project, slug):
try:
plugin = plugins.get(slug)
except KeyError:
return HttpResponseRedirect(reverse('sentry-manage-project', args=[project.organization.slug, project.slug]))
if not plugin.can_configure_for_project(project):
return HttpResponseRedirect(reverse('sentry-manage-project', args=[project.organization.slug, project.slug]))
view = plugin.configure(request, project=project)
if isinstance(view, HttpResponse):
return view
context = csrf(request)
context.update({
'organization': organization,
'team': project.team,
'page': 'plugin',
'title': plugin.get_title(),
'view': view,
'project': project,
'plugin': plugin,
'plugin_is_enabled': plugin.is_enabled(project),
})
return render_to_response('sentry/projects/plugins/configure.html',
context, request)
示例5: test_disable_plugin_when_fully_migrated
def test_disable_plugin_when_fully_migrated(self):
self._stub_github()
project = Project.objects.create(
organization_id=self.organization.id,
)
plugin = plugins.get('github')
plugin.enable(project)
# Accessible to new Integration - mocked in _stub_github
Repository.objects.create(
organization_id=self.organization.id,
name='Test-Organization/foo',
url='https://github.com/Test-Organization/foo',
provider='github',
external_id='123',
config={
'name': 'Test-Organization/foo',
},
)
# Enabled before
assert 'github' in [p.slug for p in plugins.for_project(project)]
with self.tasks():
self.assert_setup_flow()
# Disabled after Integration installed
assert 'github' not in [p.slug for p in plugins.for_project(project)]
示例6: test_integrated
def test_integrated(self):
event = self.create_event()
action_data = {
'id': 'sentry.rules.actions.notify_event.NotifyEventAction',
}
condition_data = {
'id': 'sentry.rules.conditions.every_event.EveryEventCondition',
}
Rule.objects.filter(project=event.project).delete()
rule = Rule.objects.create(
project=event.project,
data={
'conditions': [condition_data],
'actions': [action_data],
}
)
rp = RuleProcessor(event, is_new=True, is_regression=True, is_sample=False)
results = list(rp.apply())
assert len(results) == 1
callback, futures = results[0]
assert callback == plugins.get('mail').rule_notify
assert len(futures) == 1
assert futures[0].rule == rule
assert futures[0].kwargs == {}
示例7: after
def after(self, event, state):
service = self.get_option('service')
extra = {'event_id': event.id}
if not service:
self.logger.info('rules.fail.is_configured', extra=extra)
return
app = None
try:
app = SentryApp.objects.get(slug=service)
except SentryApp.DoesNotExist:
pass
if app:
kwargs = {'sentry_app': app}
metrics.incr('notifications.sent', instance=app.slug, skip_internal=False)
yield self.future(notify_sentry_app, **kwargs)
else:
plugin = plugins.get(service)
if not plugin.is_enabled(self.project):
extra['project_id'] = self.project.id
self.logger.info('rules.fail.is_enabled', extra=extra)
return
group = event.group
if not plugin.should_notify(group=group, event=event):
extra['group_id'] = group.id
self.logger.info('rule.fail.should_notify', extra=extra)
return
metrics.incr('notifications.sent', instance=plugin.slug, skip_internal=False)
yield self.future(plugin.rule_notify)
示例8: configure_project_plugin
def configure_project_plugin(request, project, slug):
try:
plugin = plugins.get(slug)
except KeyError:
return HttpResponseRedirect(reverse('sentry-manage-project', args=[project.slug]))
if not plugin.is_enabled(project):
return HttpResponseRedirect(reverse('sentry-manage-project', args=[project.slug]))
result = plugins.first('has_perm', request.user, 'configure_project_plugin', project, plugin)
if result is False and not request.user.is_superuser:
return HttpResponseRedirect(reverse('sentry'))
form = plugin.project_conf_form
if form is None:
return HttpResponseRedirect(reverse('sentry-manage-project', args=[project.slug]))
action, view = plugin_config(plugin, project, request)
if action == 'redirect':
return HttpResponseRedirect(request.path + '?success=1')
context = csrf(request)
context.update({
'page': 'plugin',
'title': plugin.get_title(),
'view': view,
'project': project,
'plugin': plugin,
})
return render_to_response('sentry/projects/plugins/configure.html', context, request)
示例9: handle
def handle(self, request, organization, team, project, slug):
try:
plugin = plugins.get(slug)
except KeyError:
return self.redirect(reverse('sentry-manage-project', args=[project.organization.slug, project.slug]))
if not plugin.can_configure_for_project(project):
return self.redirect(reverse('sentry-manage-project', args=[project.organization.slug, project.slug]))
issue_v2_plugin = None
is_enabled = plugin.is_enabled(project)
if isinstance(plugin, IssueTrackingPlugin2):
view = None
issue_v2_plugin = {
'title': plugin.get_title(),
'slug': plugin.slug,
'can_disable': plugin.can_disable,
'is_enabled': is_enabled
}
else:
view = plugin.configure(request=request, project=project)
if isinstance(view, HttpResponse):
return view
context = {
'page': 'plugin',
'title': plugin.get_title(),
'view': view,
'plugin': plugin,
'plugin_is_enabled': is_enabled,
'issue_v2_plugin': issue_v2_plugin
}
return self.respond('sentry/projects/plugins/configure.html', context)
示例10: _handle_disable_plugin
def _handle_disable_plugin(self, request, project):
plugin = plugins.get(request.POST['plugin'])
plugin.set_option('enabled', False, project)
messages.add_message(
request, messages.SUCCESS,
constants.OK_PLUGIN_DISABLED.format(name=plugin.get_title()),
)
示例11: configure_project_plugin
def configure_project_plugin(request, project, slug):
try:
plugin = plugins.get(slug)
except KeyError:
return HttpResponseRedirect(reverse("sentry-manage-project", args=[project.slug]))
if not plugin.is_enabled(project):
return HttpResponseRedirect(reverse("sentry-manage-project", args=[project.slug]))
result = plugins.first("has_perm", request.user, "configure_project_plugin", project, plugin)
if result is False and not request.user.is_superuser:
return HttpResponseRedirect(reverse("sentry"))
form = plugin.project_conf_form
if form is None:
return HttpResponseRedirect(reverse("sentry-manage-project", args=[project.slug]))
action, view = plugin_config(plugin, project, request)
if action == "redirect":
return HttpResponseRedirect(request.path + "?success=1")
context = csrf(request)
context.update({"page": "plugin", "title": plugin.get_title(), "view": view, "project": project, "plugin": plugin})
return render_to_response("sentry/projects/plugins/configure.html", context, request)
示例12: post
def post(self, request, plugin_id, project_id, signature):
project = Project.objects.get_from_cache(id=project_id)
token = ProjectOption.objects.get_value(project, 'sentry:release-token')
logger.info('Incoming webhook for project_id=%s, plugin_id=%s',
project_id, plugin_id)
if not self.verify(plugin_id, project_id, token, signature):
logger.warn('Unable to verify signature for release hook')
return HttpResponse(status=403)
if plugin_id == 'builtin':
return self._handle_builtin(request, project)
plugin = plugins.get(plugin_id)
if not plugin.is_enabled(project):
logger.warn('Disabled release hook received for project_id=%s, plugin_id=%s',
project_id, plugin_id)
return HttpResponse(status=403)
cls = plugin.get_release_hook()
hook = cls(project)
hook.handle(request)
return HttpResponse(status=204)
示例13: handle
def handle(self, request, organization, team, project, slug):
try:
plugin = plugins.get(slug)
except KeyError:
return self.redirect(reverse('sentry-manage-project', args=[project.organization.slug, project.slug]))
if not plugin.can_configure_for_project(project):
return self.redirect(reverse('sentry-manage-project', args=[project.organization.slug, project.slug]))
react_plugin = None
is_enabled = plugin.is_enabled(project)
if isinstance(plugin, IssueTrackingPlugin2) or isinstance(plugin, NotificationPlugin):
view = None
response = client.get('/projects/{}/{}/plugins/{}/'.format(
organization.slug,
project.slug,
slug,
), request=request)
react_plugin = response.data
else:
view = plugin.configure(request=request, project=project)
if isinstance(view, HttpResponse):
return view
context = {
'page': 'plugin',
'title': plugin.get_title(),
'view': view,
'plugin': plugin,
'plugin_is_enabled': is_enabled,
'react_plugin': react_plugin,
}
return self.respond('sentry/projects/plugins/configure.html', context)
示例14: post
def post(self, request, plugin_id, project_id, signature):
project = Project.objects.get_from_cache(id=project_id)
token = ProjectOption.objects.get_value(project, 'sentry:release-token')
logger.info('Incoming webhook for project_id=%s, plugin_id=%s',
project_id, plugin_id)
if not self.verify(plugin_id, project_id, token, signature):
logger.warn('Unable to verify signature for release hook')
return HttpResponse(status=403)
if plugin_id == 'builtin':
return self._handle_builtin(request, project)
plugin = plugins.get(plugin_id)
if not plugin.is_enabled(project):
logger.warn('Disabled release hook received for project_id=%s, plugin_id=%s',
project_id, plugin_id)
return HttpResponse(status=403)
cls = plugin.get_release_hook()
hook = cls(project)
try:
hook.handle(request)
except HookValidationError as exc:
return HttpResponse(
status=400,
content=json.dumps({'error': six.text_type(exc)}),
content_type='application/json',
)
return HttpResponse(status=204)
示例15: post
def post(self, request, organization, team, project, slug):
try:
plugin = plugins.get(slug)
except KeyError:
return self.redirect(
reverse(
'sentry-configure-project-plugin',
args=[project.organization.slug, project.slug, slug]
)
)
if not plugin.is_enabled(project):
return self.redirect(
reverse(
'sentry-configure-project-plugin',
args=[project.organization.slug, project.slug, slug]
)
)
plugin.disable(project=project)
return self.redirect(
reverse(
'sentry-configure-project-plugin',
args=[project.organization.slug, project.slug, slug]
)
)