本文整理汇总了Python中sentry.plugins.register函数的典型用法代码示例。如果您正苦于以下问题:Python register函数的具体用法?Python register怎么用?Python register使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了register函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: install_plugins
def install_plugins(settings):
from sentry.plugins import register
# entry_points={
# 'sentry.plugins': [
# 'phabricator = sentry_phabricator.plugins:PhabricatorPlugin'
# ],
# },
installed_apps = list(settings.INSTALLED_APPS)
for ep in pkg_resources.iter_entry_points('sentry.apps'):
try:
plugin = ep.load()
except Exception:
import sys
import traceback
print >> sys.stderr, "Failed to load app %r:\n%s" % (ep.name, traceback.format_exc())
else:
installed_apps.append(ep.module_name)
settings.INSTALLED_APPS = tuple(installed_apps)
for ep in pkg_resources.iter_entry_points('sentry.plugins'):
try:
plugin = ep.load()
except Exception:
import sys
import traceback
print >> sys.stderr, "Failed to load plugin %r:\n%s" % (ep.name, traceback.format_exc())
else:
register(plugin)
示例2: register_plugins
def register_plugins(settings):
from pkg_resources import iter_entry_points
from sentry.plugins import register
# entry_points={
# 'sentry.plugins': [
# 'phabricator = sentry_phabricator.plugins:PhabricatorPlugin'
# ],
# },
for ep in iter_entry_points('sentry.plugins'):
try:
plugin = ep.load()
except Exception:
import traceback
click.echo("Failed to load plugin %r:\n%s" % (ep.name, traceback.format_exc()), err=True)
else:
register(plugin)
示例3: register_plugins
def register_plugins(settings):
from sentry.plugins import register
# entry_points={
# 'sentry.plugins': [
# 'phabricator = sentry_phabricator.plugins:PhabricatorPlugin'
# ],
# },
for ep in pkg_resources.iter_entry_points('sentry.plugins'):
try:
plugin = ep.load()
except Exception:
import sys
import traceback
sys.stderr.write("Failed to load plugin %r:\n%s\n" % (ep.name, traceback.format_exc()))
else:
register(plugin)
示例4: FacebookPlugin
from sentry.plugins import Plugin, register
class FacebookPlugin(Plugin):
title = 'Facebook'
slug = 'facebook'
version = '0.1'
author = 'George Marshall'
register(FacebookPlugin)
示例5: UrlsPlugin
from django.utils.translation import ugettext_lazy as _
from sentry.plugins import register
from sentry.plugins.bases.tag import TagPlugin
class UrlsPlugin(TagPlugin):
"""
Automatically adds the 'url' tag from events containing interface data
from ``sentry.interfaces.Http``.
"""
slug = 'urls'
title = _('Auto Tag: URLs')
version = sentry.VERSION
author = "Sentry Team"
author_url = "https://github.com/getsentry/sentry"
tag = 'url'
tag_label = _('URL')
project_default_enabled = True
def get_tag_values(self, event):
http = event.interfaces.get('sentry.interfaces.Http')
if not http:
return []
if not http.url:
return []
return [http.url]
register(UrlsPlugin)
示例6: get_option
'group': group,
'event': event,
'link': link,
'interfaces': interface_list,
})).run()
headers = {
'X-Sentry-Logger': event.logger,
'X-Sentry-Logger-Level': event.get_level_display(),
'X-Sentry-Project': project.name,
'X-Sentry-Server': event.server_name,
}
self._send_mail(
subject=subject,
body=body,
html_body=html_body,
project=project,
fail_silently=fail_silently,
headers=headers,
)
def get_option(self, key, *args, **kwargs):
value = super(MailProcessor, self).get_option(key, *args, **kwargs)
if value is None and key in ('min_level', 'include_loggers', 'exclude_loggers',
'send_to_members', 'send_to_admins', 'send_to',
'subject_prefix'):
value = getattr(self, key)
return value
register(MailProcessor)
示例7: notify_digest
self._send_mail(
subject=subject,
template=template,
html_template=html_template,
project=project,
group=group,
headers=headers,
context=context,
)
def notify_digest(self, project, digest):
context = {
'project': project,
'digest': digest,
}
self._send_mail(
subject=render_to_string('sentry/emails/digests/subject.txt', context).rstrip(),
template='sentry/emails/digests/body.txt',
html_template='sentry/emails/digests/body.html',
project=project,
context=context,
)
# Legacy compatibility
MailProcessor = MailPlugin
register(MailPlugin)
示例8: ServersPlugin
if queryset.model == Event:
return queryset.filter(server_name=self.get_value()).distinct()
else:
return queryset.filter(event_set__server_name=self.get_value()).distinct()
class ServersPlugin(TagPlugin):
"""
Adds additional support for showing information about servers including:
* A panel which shows all servers a message was seen on.
* A sidebar module which shows the servers most actively seen on.
"""
slug = 'servers'
title = _('Servers')
version = sentry.VERSION
author = "Sentry Team"
author_url = "https://github.com/dcramer/sentry"
tag = 'server_name'
tag_label = _('Server Name')
def get_tag_values(self, event):
if not event.server_name:
return []
return [event.server_name]
def get_filters(self, project=None, **kwargs):
return [ServerNameFilter]
register(ServersPlugin)
示例9: post_process
title = 'JSON Mailer'
conf_title = title
conf_key = 'jsonmailprocessor'
# We want all events, not just new ones, so we override
# this method to remove the is_new check.
def post_process(self, group, event, is_new, is_sample, **kwargs):
if not self.should_notify(group, event):
return
self.notify_users(group, event)
# Overrides the method from MailProcessor
def get_plaintext_body(self, group, event, link, interface_list):
header = "SENTRY_EVENT_MAIL"
event.data['date_local_tz'] = str(timezone.localtime(event.datetime))
data = {
'server_name' : event.server_name,
'culprit' : event.culprit,
'level' : event.level,
'event_id' : event.event_id,
'message' : event.message,
'date' : str(event.datetime),
'data': event.data
}
return " ".join([header, json.dumps(data, separators=(',', ':'))])
register(JsonMailProcessor)
示例10: _
title = _('Browsers')
tag = 'browser'
tag_label = _('Browser Name')
def get_tag_from_ua(self, ua):
if 'browser' not in ua:
return
tag = ua['browser']['name']
if 'version' in ua['browser']:
tag += ' ' + ua['browser']['version']
return tag
register(BrowserPlugin)
class OsPlugin(UserAgentPlugin):
"""
Adds additional support for showing information about operating systems including:
* A panel which shows all operating systems a message was seen on.
* A sidebar module which shows the operating systems most actively seen on.
"""
slug = 'os'
title = _('Operating Systems')
tag = 'os'
tag_label = _('Operating System')
def get_tag_from_ua(self, ua):
示例11: UserEmailsPlugin
from django.utils.translation import ugettext_lazy as _
from sentry.plugins import register
from sentry.plugins.bases.tag import TagPlugin
class UserEmailsPlugin(TagPlugin):
"""
Adds additional support for showing information about users including:
* A panel which shows all users a message was created by.
* A sidebar module which shows the users most actively seeing event.
"""
slug = 'user-emails'
title = _('Auto Tag: User Emails')
version = sentry.VERSION
author = "Sentry Team"
author_url = "https://github.com/getsentry/sentry"
tag = 'user_email'
tag_label = _('User Email')
def get_tag_values(self, event):
user = event.interfaces.get('sentry.interfaces.User')
if not user:
return []
if not getattr(user, 'email', None):
return []
return [user.email]
register(UserEmailsPlugin)
示例12: __init__
base_fields = [RULES_DATA_KEY]
def __init__(self, *args, **kwargs):
initial = kwargs.get('initial', {}).get(RULES_DATA_KEY)
if initial:
kwargs['initial'] = pickle.loads(initial)
super(PatchedGroupRuleFormSet, self).__init__(*args, **kwargs)
@property
def cleaned_data(self):
data = getattr(super(PatchedGroupRuleFormSet, self), 'cleaned_data', {})
return {RULES_DATA_KEY: pickle.dumps(data)}
class GrouperPlugin(Plugin):
slug = 'group_rules'
conf_key = 'group_rules'
conf_key_rules = RULES_DATA_KEY
title = _('Grouping Rules')
version = sentry_grouper.VERSION
author = "Tommaso Barbugli"
author_url = "https://github.com/tbarbugli/sentry_grouper"
project_conf_template = 'sentry/plugins/sentry_grouper/project_configuration.html'
project_conf_form = PatchedGroupRuleFormSet
def get_project_rules(self, project):
rules = self.get_option(RULES_DATA_KEY, project)
unpickled = rules and pickle.loads(rules) or {RULES_DATA_KEY: []}
return unpickled
register(GrouperPlugin)
示例13: register
from __future__ import absolute_import
from sentry.plugins import register
from .plugin import WebHooksPlugin
register(WebHooksPlugin)
示例14: register
from __future__ import absolute_import, print_function
from sentry.plugins import register
from .plugin import JavascriptPlugin
register(JavascriptPlugin)
示例15: __import__
# coding: utf-8
"""
sentry_zabbix
"""
from __future__ import absolute_import
try:
VERSION = __import__('pkg_resources').get_distribution(__name__).version
except Exception, e:
VERSION = 'unknown'
from sentry.plugins import register
from .plugin import ZabbixPlugin
register(ZabbixPlugin)