本文整理汇总了Python中sentry.signals.pending_delete.send函数的典型用法代码示例。如果您正苦于以下问题:Python send函数的具体用法?Python send怎么用?Python send使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了send函数的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: delete_organization
def delete_organization(object_id, transaction_id=None, actor_id=None, **kwargs):
from sentry import deletions
from sentry.models import Organization, OrganizationStatus
try:
instance = Organization.objects.get(id=object_id)
except Organization.DoesNotExist:
return
if instance.status == OrganizationStatus.VISIBLE:
raise DeleteAborted
# compat: can be removed after we switch to scheduled deletions
if instance.status != OrganizationStatus.DELETION_IN_PROGRESS:
pending_delete.send(
sender=type(instance),
instance=instance,
)
task = deletions.get(
model=Organization,
query={
'id': object_id,
},
transaction_id=transaction_id or uuid4().hex,
actor_id=actor_id,
)
has_more = task.chunk()
if has_more:
delete_organization.apply_async(
kwargs={'object_id': object_id,
'transaction_id': transaction_id,
'actor_id': actor_id},
countdown=15,
)
示例2: delete_team
def delete_team(object_id, transaction_id=None, continuous=True, **kwargs):
from sentry.models import Team, TeamStatus, Project, ProjectStatus
try:
t = Team.objects.get(id=object_id)
except Team.DoesNotExist:
return
if t.status == TeamStatus.VISIBLE:
raise DeleteAborted('Aborting team deletion as status is invalid')
if t.status != TeamStatus.DELETION_IN_PROGRESS:
pending_delete.send(sender=Team, instance=t)
t.update(status=TeamStatus.DELETION_IN_PROGRESS)
# Delete 1 project at a time since this is expensive by itself
for project in Project.objects.filter(team=t).order_by('id')[:1]:
project.update(status=ProjectStatus.DELETION_IN_PROGRESS)
delete_project(project.id, transaction_id=transaction_id, continuous=False)
if continuous:
delete_team.apply_async(
kwargs={'object_id': object_id, 'transaction_id': transaction_id},
countdown=15,
)
return
t_id = t.id
t.delete()
logger.info('object.delete.executed', extra={
'object_id': t_id,
'transaction_id': transaction_id,
'model': Team.__name__,
})
示例3: delete_organization
def delete_organization(object_id, continuous=True, **kwargs):
from sentry.models import (
Organization, OrganizationMember, OrganizationStatus, Team, TeamStatus
)
try:
o = Organization.objects.get(id=object_id)
except Organization.DoesNotExist:
return
if o.status == OrganizationStatus.VISIBLE:
raise DeleteAborted('Aborting organization deletion as status is invalid')
if o.status != OrganizationStatus.DELETION_IN_PROGRESS:
o.update(status=OrganizationStatus.DELETION_IN_PROGRESS)
pending_delete.send(sender=Organization, instance=o)
for team in Team.objects.filter(organization=o).order_by('id')[:1]:
logger.info('Removing Team id=%s where organization=%s', team.id, o.id)
team.update(status=TeamStatus.DELETION_IN_PROGRESS)
delete_team(team.id, continuous=False)
if continuous:
delete_organization.delay(object_id=object_id, countdown=15)
return
model_list = (OrganizationMember,)
has_more = delete_objects(model_list, relation={'organization': o}, logger=logger)
if has_more:
if continuous:
delete_organization.delay(object_id=object_id, countdown=15)
return
o.delete()
示例4: generic_delete
def generic_delete(app_label, model_name, object_id, transaction_id=None,
continuous=True, actor_id=None, **kwargs):
from sentry.models import User
model = get_model(app_label, model_name)
try:
instance = model.objects.get(id=object_id)
except model.DoesNotExist:
return
if instance.status == ObjectStatus.VISIBLE:
raise DeleteAborted
if instance.status == ObjectStatus.PENDING_DELETION:
if actor_id:
actor = User.objects.get(id=actor_id)
else:
actor = None
instance.update(status=ObjectStatus.DELETION_IN_PROGRESS)
pending_delete.send(sender=model, instance=instance, actor=actor)
# TODO(dcramer): it'd be nice if we could collect relations here and
# cascade efficiently
instance_id = instance.id
instance.delete()
logger.info('object.delete.executed', extra={
'object_id': instance_id,
'transaction_id': transaction_id,
'model': model.__name__,
})
示例5: delete_team
def delete_team(object_id, continuous=True, **kwargs):
from sentry.models import Team, TeamStatus, Project, ProjectStatus
try:
t = Team.objects.get(id=object_id)
except Team.DoesNotExist:
return
if t.status == TeamStatus.VISIBLE:
raise DeleteAborted('Aborting team deletion as status is invalid')
if t.status != TeamStatus.DELETION_IN_PROGRESS:
pending_delete.send(sender=Team, instance=t)
t.update(status=TeamStatus.DELETION_IN_PROGRESS)
# Delete 1 project at a time since this is expensive by itself
for project in Project.objects.filter(team=t).order_by('id')[:1]:
logger.info('Removing Project id=%s where team=%s', project.id, t.id)
project.update(status=ProjectStatus.DELETION_IN_PROGRESS)
delete_project(project.id, continuous=False)
if continuous:
delete_team.delay(object_id=object_id, countdown=15)
return
t.delete()
示例6: delete_instance
def delete_instance(self, instance):
pending_delete.send(
sender=type(instance),
instance=instance,
actor=self.get_actor(),
)
return super(RepositoryDeletionTask, self).delete_instance(instance)
示例7: delete_project
def delete_project(object_id, continuous=True, **kwargs):
from sentry.models import (
Activity, EventMapping, Group, GroupAssignee, GroupBookmark,
GroupEmailThread, GroupHash, GroupMeta, GroupResolution,
GroupRuleStatus, GroupSeen, GroupTagKey, GroupTagValue, Project,
ProjectKey, ProjectStatus, SavedSearchUserDefault, SavedSearch, TagKey,
TagValue, UserReport
)
try:
p = Project.objects.get(id=object_id)
except Project.DoesNotExist:
return
if p.status == ProjectStatus.VISIBLE:
raise DeleteAborted('Aborting project deletion as status is invalid')
if p.status != ProjectStatus.DELETION_IN_PROGRESS:
pending_delete.send(sender=Project, instance=p)
p.update(status=ProjectStatus.DELETION_IN_PROGRESS)
# XXX: remove keys first to prevent additional data from flowing in
model_list = (
Activity, EventMapping, GroupAssignee, GroupBookmark, GroupEmailThread,
GroupHash, GroupSeen, GroupRuleStatus, GroupTagKey,
GroupTagValue, ProjectKey, TagKey, TagValue, SavedSearchUserDefault,
SavedSearch, UserReport
)
for model in model_list:
has_more = bulk_delete_objects(model, project_id=p.id, logger=logger)
if has_more:
if continuous:
delete_project.delay(object_id=object_id, countdown=15)
return
# TODO(dcramer): no project relation so we cant easily bulk
# delete today
has_more = delete_objects([GroupMeta, GroupResolution],
relation={'group__project': p},
logger=logger)
if has_more:
if continuous:
delete_project.delay(object_id=object_id, countdown=15)
return
has_more = delete_events(relation={'project_id': p.id}, logger=logger)
if has_more:
if continuous:
delete_project.delay(object_id=object_id, countdown=15)
return
model_list = (Group,)
for model in model_list:
has_more = bulk_delete_objects(model, project_id=p.id, logger=logger)
if has_more:
if continuous:
delete_project.delay(object_id=object_id, countdown=15)
return
p.delete()
示例8: delete_organization
def delete_organization(object_id, transaction_id=None, continuous=True, **kwargs):
from sentry.models import (
Organization, OrganizationMember, OrganizationStatus, Team, TeamStatus,
Commit, CommitAuthor, CommitFileChange, Environment, Release, ReleaseCommit,
ReleaseEnvironment, ReleaseFile, ReleaseHeadCommit, Repository
)
try:
o = Organization.objects.get(id=object_id)
except Organization.DoesNotExist:
return
if o.status == OrganizationStatus.VISIBLE:
raise DeleteAborted('Aborting organization deletion as status is invalid')
if o.status != OrganizationStatus.DELETION_IN_PROGRESS:
o.update(status=OrganizationStatus.DELETION_IN_PROGRESS)
pending_delete.send(sender=Organization, instance=o)
for team in Team.objects.filter(organization=o).order_by('id')[:1]:
team.update(status=TeamStatus.DELETION_IN_PROGRESS)
delete_team(team.id, transaction_id=transaction_id, continuous=False)
if continuous:
delete_organization.apply_async(
kwargs={'object_id': object_id, 'transaction_id': transaction_id},
countdown=15,
)
return
model_list = (
OrganizationMember, CommitFileChange, Commit, CommitAuthor,
Environment, Repository, Release, ReleaseCommit,
ReleaseEnvironment, ReleaseFile, ReleaseHeadCommit
)
has_more = delete_objects(
model_list,
transaction_id=transaction_id,
relation={'organization_id': o.id},
logger=logger,
)
if has_more:
if continuous:
delete_organization.apply_async(
kwargs={'object_id': object_id, 'transaction_id': transaction_id},
countdown=15,
)
return
o_id = o.id
o.delete()
logger.info('object.delete.executed', extra={
'object_id': o_id,
'transaction_id': transaction_id,
'model': Organization.__name__,
})
示例9: delete_project
def delete_project(object_id, continuous=True, **kwargs):
from sentry.models import (
Project, ProjectKey, ProjectStatus, TagKey, TagValue, GroupTagKey,
GroupTagValue, Activity, EventMapping, Group, GroupEmailThread,
GroupRuleStatus, GroupHash, GroupSeen, UserReport
)
try:
p = Project.objects.get(id=object_id)
except Project.DoesNotExist:
return
if p.status == ProjectStatus.VISIBLE:
raise DeleteAborted('Aborting project deletion as status is invalid')
if p.status != ProjectStatus.DELETION_IN_PROGRESS:
pending_delete.send(sender=Project, instance=p)
p.update(status=ProjectStatus.DELETION_IN_PROGRESS)
# XXX: remove keys first to prevent additional data from flowing in
model_list = (
ProjectKey, TagKey, TagValue, GroupTagKey, GroupTagValue, EventMapping,
Activity, GroupRuleStatus, GroupHash, GroupSeen, UserReport,
GroupEmailThread
)
for model in model_list:
has_more = bulk_delete_objects(model, project_id=p.id, logger=logger)
if has_more:
if continuous:
delete_project.delay(object_id=object_id, countdown=15)
return
has_more = delete_events(relation={'project_id': p.id}, logger=logger)
if has_more:
if continuous:
delete_project.delay(object_id=object_id, countdown=15)
return
model_list = (Group,)
for model in model_list:
has_more = bulk_delete_objects(model, project_id=p.id, logger=logger)
if has_more:
if continuous:
delete_project.delay(object_id=object_id, countdown=15)
return
p.delete()
示例10: generic_delete
def generic_delete(app_label, model_name, object_id, transaction_id=None, actor_id=None, **kwargs):
from sentry import deletions
from sentry.models import User
model = get_model(app_label, model_name)
try:
instance = model.objects.get(id=object_id)
except model.DoesNotExist:
return
if instance.status != ObjectStatus.DELETION_IN_PROGRESS:
pending_delete.send(
sender=type(instance),
instance=instance,
actor=User.objects.get(id=actor_id) if actor_id else None,
)
if instance.status == ObjectStatus.VISIBLE:
raise DeleteAborted
task = deletions.get(
model=model,
actor_id=actor_id,
query={
'id': object_id,
},
transaction_id=transaction_id or uuid4().hex,
)
has_more = task.chunk()
if has_more:
generic_delete.apply_async(
kwargs={
'app_label': app_label,
'model_name': model_name,
'object_id': object_id,
'transaction_id': transaction_id,
'actor_id': actor_id,
},
countdown=15,
)
示例11: run_deletion
def run_deletion(deletion_id):
from sentry import deletions
from sentry.models import ScheduledDeletion
try:
deletion = ScheduledDeletion.objects.get(
id=deletion_id,
)
except ScheduledDeletion.DoesNotExist:
return
if deletion.aborted:
raise DeleteAborted
if not deletion.in_progress:
actor = deletion.get_actor()
instance = deletion.get_instance()
with transaction.atomic():
deletion.update(in_progress=True)
pending_delete.send(
sender=type(instance),
instance=instance,
actor=actor,
)
task = deletions.get(
model=deletion.get_model(),
query={
'id': deletion.object_id,
},
transaction_id=deletion.guid,
actor_id=deletion.actor_id,
)
has_more = task.chunk()
if has_more:
run_deletion.apply_async(
kwargs={'deletion_id': deletion_id},
countdown=15,
)
deletion.delete()
示例12: delete_project
def delete_project(object_id, transaction_id=None, continuous=True, **kwargs):
from sentry.models import (
Activity, EventMapping, EventUser, Group, GroupAssignee, GroupBookmark,
GroupEmailThread, GroupHash, GroupMeta, GroupRelease, GroupResolution,
GroupRuleStatus, GroupSeen, GroupSubscription, GroupSnooze, GroupTagKey,
GroupTagValue, Project, ProjectBookmark, ProjectKey, ProjectStatus,
Release, ReleaseFile, SavedSearchUserDefault, SavedSearch, TagKey,
TagValue, UserReport, ReleaseEnvironment, Environment
)
try:
p = Project.objects.get(id=object_id)
except Project.DoesNotExist:
return
if p.status == ProjectStatus.VISIBLE:
raise DeleteAborted('Aborting project deletion as status is invalid')
if p.status != ProjectStatus.DELETION_IN_PROGRESS:
pending_delete.send(sender=Project, instance=p)
p.update(status=ProjectStatus.DELETION_IN_PROGRESS)
# Immediately revoke keys
project_keys = list(ProjectKey.objects.filter(project_id=object_id).values_list('id', flat=True))
ProjectKey.objects.filter(project_id=object_id).delete()
for key_id in project_keys:
logger.info('object.delete.executed', extra={
'object_id': key_id,
'transaction_id': transaction_id,
'model': ProjectKey.__name__,
})
model_list = (
Activity, EventMapping, EventUser, GroupAssignee, GroupBookmark,
GroupEmailThread, GroupHash, GroupRelease, GroupRuleStatus, GroupSeen,
GroupSubscription, GroupTagKey, GroupTagValue, ProjectBookmark,
ProjectKey, TagKey, TagValue, SavedSearchUserDefault, SavedSearch,
UserReport, ReleaseEnvironment, Environment
)
for model in model_list:
has_more = bulk_delete_objects(model, project_id=p.id, transaction_id=transaction_id, logger=logger)
if has_more:
if continuous:
delete_project.apply_async(
kwargs={'object_id': object_id, 'transaction_id': transaction_id},
countdown=15,
)
return
# TODO(dcramer): no project relation so we cant easily bulk
# delete today
has_more = delete_objects([GroupMeta, GroupResolution, GroupSnooze],
relation={'group__project': p},
transaction_id=transaction_id,
logger=logger)
if has_more:
if continuous:
delete_project.apply_async(
kwargs={'object_id': object_id, 'transaction_id': transaction_id},
countdown=15,
)
return
has_more = delete_events(relation={'project_id': p.id}, transaction_id=transaction_id, logger=logger)
if has_more:
if continuous:
delete_project.apply_async(
kwargs={'object_id': object_id, 'transaction_id': transaction_id},
)
return
# Release needs to handle deletes after Group is cleaned up as the foreign
# key is protected
model_list = (Group, ReleaseFile, Release)
for model in model_list:
has_more = bulk_delete_objects(model, project_id=p.id, transaction_id=transaction_id, logger=logger)
if has_more:
if continuous:
delete_project.apply_async(
kwargs={'object_id': object_id, 'transaction_id': transaction_id},
countdown=15,
)
return
p_id = p.id
p.delete()
logger.info('object.delete.queued', extra={
'object_id': p_id,
'transaction_id': transaction_id,
'model': Project.__name__,
})
示例13: delete_project
def delete_project(object_id, continuous=True, **kwargs):
from sentry.models import (
Activity, EventMapping, Group, GroupAssignee, GroupBookmark,
GroupEmailThread, GroupHash, GroupMeta, GroupResolution,
GroupRuleStatus, GroupSeen, GroupTagKey, GroupTagValue, Project,
ProjectBookmark, ProjectKey, ProjectStatus, Release, ReleaseFile,
SavedSearchUserDefault, SavedSearch, TagKey, TagValue, UserReport
)
try:
p = Project.objects.get(id=object_id)
except Project.DoesNotExist:
return
if p.status == ProjectStatus.VISIBLE:
raise DeleteAborted('Aborting project deletion as status is invalid')
if p.status != ProjectStatus.DELETION_IN_PROGRESS:
pending_delete.send(sender=Project, instance=p)
p.update(status=ProjectStatus.DELETION_IN_PROGRESS)
# Immediately revoke keys
ProjectKey.objects.filter(project_id=object_id).delete()
model_list = (
Activity, EventMapping, GroupAssignee, GroupBookmark, GroupEmailThread,
GroupHash, GroupSeen, GroupRuleStatus, GroupTagKey, GroupTagValue,
ProjectBookmark, ProjectKey, TagKey, TagValue, SavedSearchUserDefault,
SavedSearch, UserReport
)
for model in model_list:
has_more = bulk_delete_objects(model, project_id=p.id, logger=logger)
if has_more:
if continuous:
delete_project.delay(object_id=object_id, countdown=15)
return
# TODO(dcramer): no project relation so we cant easily bulk
# delete today
has_more = delete_objects([GroupMeta, GroupResolution],
relation={'group__project': p},
logger=logger)
if has_more:
if continuous:
delete_project.delay(object_id=object_id, countdown=15)
return
has_more = delete_events(relation={'project_id': p.id}, logger=logger)
if has_more:
if continuous:
delete_project.delay(object_id=object_id, countdown=15)
return
# Release needs to handle deletes after Group is cleaned up as the foreign
# key is protected
model_list = (Group, ReleaseFile, Release)
for model in model_list:
has_more = bulk_delete_objects(model, project_id=p.id, logger=logger)
if has_more:
if continuous:
delete_project.delay(object_id=object_id, countdown=15)
return
p.delete()