本文整理汇总了Python中sentry.plugins.plugins.for_project函数的典型用法代码示例。如果您正苦于以下问题:Python for_project函数的具体用法?Python for_project怎么用?Python for_project使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了for_project函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: 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)]
示例2: get_attrs
def get_attrs(self, item_list, user):
from sentry.plugins import plugins
GroupMeta.objects.populate_cache(item_list)
attach_foreignkey(item_list, Group.project, ['team'])
if user.is_authenticated() and item_list:
bookmarks = set(GroupBookmark.objects.filter(
user=user,
group__in=item_list,
).values_list('group_id', flat=True))
seen_groups = dict(GroupSeen.objects.filter(
user=user,
group__in=item_list,
).values_list('group_id', 'last_seen'))
else:
bookmarks = set()
seen_groups = {}
assignees = dict(
(a.group_id, a.user)
for a in GroupAssignee.objects.filter(
group__in=item_list,
).select_related('user')
)
user_counts = dict(
GroupTagKey.objects.filter(
group__in=item_list,
key='sentry:user',
).values_list('group', 'values_seen')
)
snoozes = dict(
GroupSnooze.objects.filter(
group__in=item_list,
).values_list('group', 'until')
)
result = {}
for item in item_list:
active_date = item.active_at or item.last_seen
annotations = []
for plugin in plugins.for_project(project=item.project, version=1):
safe_execute(plugin.tags, None, item, annotations)
for plugin in plugins.for_project(project=item.project, version=2):
annotations.extend(safe_execute(plugin.get_annotations, group=item) or ())
result[item] = {
'assigned_to': serialize(assignees.get(item.id)),
'is_bookmarked': item.id in bookmarks,
'has_seen': seen_groups.get(item.id, active_date) > active_date,
'annotations': annotations,
'user_count': user_counts.get(item.id, 0),
'snooze': snoozes.get(item.id),
}
return result
示例3: test_disable_for_all_projects
def test_disable_for_all_projects(self):
plugin = plugins.get('example')
plugin.enable(self.project)
assert plugin in plugins.for_project(self.project)
self.migrator.disable_for_all_projects(plugin)
assert plugin not in plugins.for_project(self.project)
示例4: get_attrs
def get_attrs(self, item_list, user):
from sentry.plugins import plugins
GroupMeta.objects.populate_cache(item_list)
attach_foreignkey(item_list, Group.project, ["team"])
if user.is_authenticated() and item_list:
bookmarks = set(
GroupBookmark.objects.filter(user=user, group__in=item_list).values_list("group_id", flat=True)
)
seen_groups = dict(
GroupSeen.objects.filter(user=user, group__in=item_list).values_list("group_id", "last_seen")
)
else:
bookmarks = set()
seen_groups = {}
tag_counts = defaultdict(dict)
tag_results = GroupTagKey.objects.filter(group__in=item_list).values_list("key", "group", "values_seen")
for key, group_id, values_seen in tag_results:
tag_counts[key][group_id] = values_seen
assignees = dict(
(a.group_id, a.user) for a in GroupAssignee.objects.filter(group__in=item_list).select_related("user")
)
result = {}
for item in item_list:
active_date = item.active_at or item.last_seen
tags = {}
for key in tag_counts.iterkeys():
label = TAG_LABELS.get(key, key.replace("_", " ")).lower()
try:
value = tag_counts[key].get(item.id, 0)
except KeyError:
value = 0
tags[key] = {"label": label, "count": value}
annotations = []
for plugin in plugins.for_project(project=item.project, version=1):
safe_execute(plugin.tags, None, item, annotations)
for plugin in plugins.for_project(project=item.project, version=2):
annotations.extend(safe_execute(plugin.get_annotations, item) or ())
result[item] = {
"assigned_to": serialize(assignees.get(item.id)),
"is_bookmarked": item.id in bookmarks,
"has_seen": seen_groups.get(item.id, active_date) > active_date,
"tags": tags,
"annotations": annotations,
}
return result
示例5: get_plugins
def get_plugins(self):
from sentry.plugins.bases.notify import NotificationPlugin
results = []
for plugin in plugins.for_project(self.project, version=1):
if not isinstance(plugin, NotificationPlugin):
continue
results.append(plugin)
for plugin in plugins.for_project(self.project, version=2):
for notifier in (safe_execute(plugin.get_notifiers, _with_transaction=False) or ()):
results.append(notifier)
return results
示例6: get_activity_notifiers
def get_activity_notifiers(project):
from sentry.plugins.bases.notify import NotificationPlugin
from sentry.plugins import plugins
results = []
for plugin in plugins.for_project(project, version=1):
if isinstance(plugin, NotificationPlugin):
results.append(plugin)
for plugin in plugins.for_project(project, version=2):
for notifier in (safe_execute(plugin.get_notifiers, _with_transaction=False) or ()):
results.append(notifier)
return results
示例7: post_process_group
def post_process_group(event, is_new, is_regression, is_sample, **kwargs):
"""
Fires post processing hooks for a group.
"""
from sentry.models import Project
from sentry.rules.processor import RuleProcessor
project = Project.objects.get_from_cache(id=event.group.project_id)
if settings.SENTRY_ENABLE_EXPLORE_CODE:
record_affected_code.delay(event=event)
if settings.SENTRY_ENABLE_EXPLORE_USERS:
record_affected_user.delay(event=event)
for plugin in plugins.for_project(project):
plugin_post_process_group.apply_async(
kwargs={
'plugin_slug': plugin.slug,
'event': event,
'is_new': is_new,
'is_regresion': is_regression,
'is_sample': is_sample,
},
expires=300,
)
rp = RuleProcessor(event, is_new, is_regression, is_sample)
# TODO(dcramer): ideally this would fanout, but serializing giant
# objects back and forth isn't super efficient
for callback, futures in rp.apply():
safe_execute(callback, event, futures)
示例8: test_doesnt_disable_plugin_when_partially_migrated
def test_doesnt_disable_plugin_when_partially_migrated(self):
self.setupPluginTest()
# Repo accessible by new Integration
Repository.objects.create(
organization_id=self.organization.id,
name=self.project_a['name'],
url=u'https://{}.visualstudio.com/_git/{}'.format(
self.vsts_account_name,
self.repo_name,
),
provider='visualstudio',
external_id=self.repo_id,
)
# Inaccessible Repo - causes plugin to stay enabled
Repository.objects.create(
organization_id=self.organization.id,
name='NotReachable',
url='https://randoaccount.visualstudio.com/Product/_git/NotReachable',
provider='visualstudio',
external_id='123456789',
)
self.assert_installation()
# Still enabled
assert 'vsts' in [p.slug for p in plugins.for_project(self.project)]
示例9: plugin_is_regression
def plugin_is_regression(group, event):
project = event.project
for plugin in plugins.for_project(project):
result = safe_execute(plugin.is_regression, group, event, version=1, _with_transaction=False)
if result is not None:
return result
return True
示例10: plugin_is_regression
def plugin_is_regression(group, event):
project = event.project
for plugin in plugins.for_project(project):
result = safe_execute(plugin.is_regression, group, event)
if result is not None:
return result
return True
示例11: post_process_group
def post_process_group(event, is_new, is_regression, is_sample, **kwargs):
"""
Fires post processing hooks for a group.
"""
from sentry.models import Project
from sentry.rules.processor import RuleProcessor
project_id = event.group.project_id
Raven.tags_context({
'project': project_id,
})
project = Project.objects.get_from_cache(id=project_id)
_capture_stats(event, is_new)
rp = RuleProcessor(event, is_new, is_regression, is_sample)
# TODO(dcramer): ideally this would fanout, but serializing giant
# objects back and forth isn't super efficient
for callback, futures in rp.apply():
safe_execute(callback, event, futures)
for plugin in plugins.for_project(project):
plugin_post_process_group(
plugin_slug=plugin.slug,
event=event,
is_new=is_new,
is_regresion=is_regression,
is_sample=is_sample,
)
示例12: post_process_group
def post_process_group(event, is_new, is_regression, is_sample, **kwargs):
"""
Fires post processing hooks for a group.
"""
from sentry.models import Project
from sentry.rules.processor import RuleProcessor
project = Project.objects.get_from_cache(id=event.group.project_id)
_capture_stats(event, is_new)
if settings.SENTRY_ENABLE_EXPLORE_CODE:
record_affected_code.delay(event=event)
record_affected_user.delay(event=event)
record_additional_tags(event=event)
rp = RuleProcessor(event, is_new, is_regression, is_sample)
# TODO(dcramer): ideally this would fanout, but serializing giant
# objects back and forth isn't super efficient
for callback, futures in rp.apply():
safe_execute(callback, event, futures)
for plugin in plugins.for_project(project):
plugin_post_process_group(
plugin_slug=plugin.slug,
event=event,
is_new=is_new,
is_regresion=is_regression,
is_sample=is_sample,
)
示例13: test_disable_plugin_when_fully_migrated
def test_disable_plugin_when_fully_migrated(self):
project = Project.objects.create(
organization_id=self.organization.id,
)
plugin = plugins.get('bitbucket')
plugin.enable(project)
# Accessible to new Integration
Repository.objects.create(
organization_id=self.organization.id,
name='sentryuser/repo',
url='https://bitbucket.org/sentryuser/repo',
provider='bitbucket',
external_id='123456',
config={'name': 'sentryuser/repo'},
)
self.client.post(
self.path,
data=self.data_from_bitbucket,
)
integration = Integration.objects.get(
provider=self.provider,
external_id=self.client_key,
)
responses.add(
responses.GET,
u'https://api.bitbucket.org/2.0/repositories/sentryuser/repo/hooks',
json={
'values': [{
'description': 'sentry-bitbucket-repo-hook',
}],
},
)
assert 'bitbucket' in [p.slug for p in plugins.for_project(project)]
with self.tasks():
BitbucketIntegrationProvider().post_install(
integration,
self.organization,
)
assert 'bitbucket' not in [p.slug for p in plugins.for_project(project)]
示例14: get_widgets
def get_widgets(group, request):
project = group.project
for plugin in plugins.for_project(project):
resp = safe_execute(plugin.widget, request, group)
if resp:
yield resp.render(request)
示例15: get_actions
def get_actions(group, request):
project = group.project
action_list = []
for plugin in plugins.for_project(project, version=1):
results = safe_execute(plugin.actions, request, group, action_list)
if not results:
continue
action_list = results
for plugin in plugins.for_project(project, version=2):
for action in (safe_execute(plugin.get_actions, request, group) or ()):
action_list.append(action)
return [(a[0], a[1], request.path == a[1]) for a in action_list]