本文整理汇总了Python中sentry.models.Release类的典型用法代码示例。如果您正苦于以下问题:Python Release类的具体用法?Python Release怎么用?Python Release使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Release类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_resolved_in_next_release
def test_resolved_in_next_release(self):
self.login_as(user=self.user)
project = self.create_project()
project.flags.has_releases = True
project.save()
group = self.create_group(project=project)
Release.get_or_create(
version='abcd',
project=project,
)
url = '/api/0/issues/{}/'.format(group.id)
response = self.client.put(
url, data={
'status': 'resolvedInNextRelease',
}
)
assert response.status_code == 200, response.content
group = Group.objects.get(
id=group.id,
project=group.project.id,
)
assert group.status == GroupStatus.RESOLVED
assert GroupResolution.objects.filter(
group=group,
).exists()
示例2: start_release
def start_release(self, version, **values):
values.setdefault('date_started', timezone.now())
affected = Release.objects.filter(
version=version,
organization_id=self.project.organization_id,
projects=self.project,
).update(**values)
if not affected:
release = Release.objects.filter(
version=version,
organization_id=self.project.organization_id,
).first()
if release:
release.update(**values)
else:
lock_key = Release.get_lock_key(self.project.organization_id, version)
lock = locks.get(lock_key, duration=5)
with TimedRetryPolicy(10)(lock.acquire):
try:
release = Release.objects.get(
version=version,
organization_id=self.project.organization_id
)
except Release.DoesNotExist:
release = Release.objects.create(
version=version,
organization_id=self.project.organization_id,
**values
)
release.add_project(self.project)
示例3: finish_release
def finish_release(self, version, **values):
if not Release.is_valid_version(version):
raise HookValidationError('Invalid release version: %s' % version)
values.setdefault('date_released', timezone.now())
try:
with transaction.atomic():
release = Release.objects.create(
version=version, organization_id=self.project.organization_id, **values
)
except IntegrityError:
release = Release.objects.get(
version=version,
organization_id=self.project.organization_id,
)
release.update(**values)
release.add_project(self.project)
Activity.objects.create(
type=Activity.RELEASE,
project=self.project,
ident=Activity.get_version_ident(version),
data={'version': version},
datetime=values['date_released'],
)
self.set_refs(release=release, **values)
示例4: get_release
def get_release(self, project, data):
if not data.get('release'):
return
return Release.get(
project=project,
version=data['release'],
)
示例5: get_release
def get_release(self, create=False):
"""Convenient helper to return the release for the current data
and optionally creates the release if it's missing. In case there
is no release info it will return `None`.
"""
release = self.data.get('release')
if not release:
return None
if not create:
return Release.get(project=self.project, version=self.data['release'])
timestamp = self.data.get('timestamp')
if timestamp is not None:
date = datetime.fromtimestamp(timestamp).replace(tzinfo=timezone.utc)
else:
date = None
return Release.get_or_create(
project=self.project,
version=self.data['release'],
date_added=date,
)
示例6: preprocess_step
def preprocess_step(self, processing_task):
frames = self.get_valid_frames()
if not frames:
logger.debug('Event %r has no frames with enough context to '
'fetch remote source', self.data['event_id'])
return False
if self.data.get('release'):
self.release = Release.get(
project=self.project,
version=self.data['release'],
)
self.populate_source_cache(frames)
return True
示例7: start_release
def start_release(self, version, **values):
if not Release.is_valid_version(version):
raise HookValidationError('Invalid release version: %s' % version)
try:
with transaction.atomic():
release = Release.objects.create(
version=version, organization_id=self.project.organization_id, **values
)
except IntegrityError:
release = Release.objects.get(
version=version,
organization_id=self.project.organization_id,
)
release.update(**values)
release.add_project(self.project)
示例8: get_tag_value_label
def get_tag_value_label(self, key, value):
label = value
if key == 'sentry:user':
if value.startswith('id:'):
label = value[len('id:'):]
elif value.startswith('email:'):
label = value[len('email:'):]
elif value.startswith('username:'):
label = value[len('username:'):]
elif value.startswith('ip:'):
label = value[len('ip:'):]
elif key == 'sentry:release':
from sentry.models import Release
label = Release.get_display_version(value)
return label
示例9: test_transfer_to_team_releases
def test_transfer_to_team_releases(self):
from_org = self.create_organization()
from_team = self.create_team(organization=from_org)
to_org = self.create_organization()
to_team = self.create_team(organization=to_org)
project = self.create_project(teams=[from_team])
environment = Environment.get_or_create(project, 'production')
release = Release.get_or_create(project=project, version='1.0')
ReleaseProjectEnvironment.objects.create(
project=project,
release=release,
environment=environment,
)
assert ReleaseProjectEnvironment.objects.filter(
project=project,
release=release,
environment=environment,
).exists()
assert ReleaseProject.objects.filter(
project=project,
release=release,
).exists()
project.transfer_to(team=to_team)
project = Project.objects.get(id=project.id)
assert project.teams.count() == 1
assert project.teams.first() == to_team
assert project.organization_id == to_org.id
assert not ReleaseProjectEnvironment.objects.filter(
project=project,
release=release,
environment=environment,
).exists()
assert not ReleaseProject.objects.filter(
project=project,
release=release,
).exists()
示例10: set_commits
def set_commits(self, version, commit_list):
"""
Commits should be ordered oldest to newest.
Calling this method will remove all existing commit history.
"""
if not Release.is_valid_version(version):
raise HookValidationError('Invalid release version: %s' % version)
project = self.project
try:
with transaction.atomic():
release = Release.objects.create(
organization_id=project.organization_id, version=version
)
except IntegrityError:
release = Release.objects.get(organization_id=project.organization_id, version=version)
release.add_project(project)
release.set_commits(commit_list)
示例11: finish_release
def finish_release(self, version, **values):
values.setdefault('date_released', timezone.now())
affected = Release.objects.filter(
version=version,
organization_id=self.project.organization_id,
projects=self.project,
).update(**values)
if not affected:
release = Release.objects.filter(
version=version,
organization_id=self.project.organization_id,
).first()
if release:
release.update(**values)
else:
lock_key = Release.get_lock_key(self.project.organization_id, version)
lock = locks.get(lock_key, duration=5)
with TimedRetryPolicy(10)(lock.acquire):
try:
release = Release.objects.get(
version=version,
organization_id=self.project.organization_id,
)
except Release.DoesNotExist:
release = Release.objects.create(
version=version,
organization_id=self.project.organization_id,
**values
)
release.add_project(self.project)
activity = Activity.objects.create(
type=Activity.RELEASE,
project=self.project,
ident=version,
data={'version': version},
datetime=values['date_released'],
)
activity.send_notification()
示例12: test_simple
def test_simple(self):
date = datetime.datetime.utcnow()
org = self.create_organization()
project = self.create_project(organization=org, name='foo')
# this shouldn't be included
release1 = Release.objects.create(
organization=org,
version='a' * 40,
date_released=date - datetime.timedelta(days=2),
)
release1.add_project(project)
release2 = Release.objects.create(
organization=org,
version='b' * 40,
date_released=date - datetime.timedelta(days=1),
)
release2.add_project(project)
release3 = Release.objects.create(
organization=org,
version='c' * 40,
date_released=date,
)
release3.add_project(project)
releases = list(Release.get_closest_releases(project, release2.version))
assert len(releases) == 2
assert releases[0] == release2
assert releases[1] == release3
示例13: save
def save(self, project, raw=False):
from sentry.tasks.post_process import index_event_tags
data = self.data
project = Project.objects.get_from_cache(id=project)
# Check to make sure we're not about to do a bunch of work that's
# already been done if we've processed an event with this ID. (This
# isn't a perfect solution -- this doesn't handle ``EventMapping`` and
# there's a race condition between here and when the event is actually
# saved, but it's an improvement. See GH-7677.)
try:
event = Event.objects.get(
project_id=project.id,
event_id=data['event_id'],
)
except Event.DoesNotExist:
pass
else:
self.logger.info(
'duplicate.found',
exc_info=True,
extra={
'event_uuid': data['event_id'],
'project_id': project.id,
'model': Event.__name__,
}
)
return event
# First we pull out our top-level (non-data attr) kwargs
event_id = data.pop('event_id')
level = data.pop('level')
transaction_name = data.pop('transaction', None)
culprit = data.pop('culprit', None)
logger_name = data.pop('logger', None)
server_name = data.pop('server_name', None)
site = data.pop('site', None)
checksum = data.pop('checksum', None)
fingerprint = data.pop('fingerprint', None)
platform = data.pop('platform', None)
release = data.pop('release', None)
dist = data.pop('dist', None)
environment = data.pop('environment', None)
# unused
time_spent = data.pop('time_spent', None)
message = data.pop('message', '')
if not culprit:
if transaction_name:
culprit = transaction_name
else:
culprit = generate_culprit(data, platform=platform)
culprit = force_text(culprit)
if transaction_name:
transaction_name = force_text(transaction_name)
recorded_timestamp = data.pop('timestamp')
date = datetime.fromtimestamp(recorded_timestamp)
date = date.replace(tzinfo=timezone.utc)
kwargs = {
'platform': platform,
}
event = Event(
project_id=project.id,
event_id=event_id,
data=data,
time_spent=time_spent,
datetime=date,
**kwargs
)
event._project_cache = project
data = event.data.data
# convert this to a dict to ensure we're only storing one value per key
# as most parts of Sentry dont currently play well with multiple values
tags = dict(data.get('tags') or [])
tags['level'] = LOG_LEVELS[level]
if logger_name:
tags['logger'] = logger_name
if server_name:
tags['server_name'] = server_name
if site:
tags['site'] = site
if environment:
tags['environment'] = environment
if transaction_name:
tags['transaction'] = transaction_name
if release:
# dont allow a conflicting 'release' tag
if 'release' in tags:
del tags['release']
release = Release.get_or_create(
project=project,
version=release,
#.........这里部分代码省略.........
示例14: get_release
def get_release(self, project, data):
if not data.get("release"):
return
return Release.get(project=project, version=data["release"])
示例15: save
def save(self, project, raw=False):
project = Project.objects.get_from_cache(id=project)
data = self.data.copy()
# First we pull out our top-level (non-data attr) kwargs
event_id = data.pop('event_id')
message = data.pop('message')
level = data.pop('level')
culprit = data.pop('culprit', None)
time_spent = data.pop('time_spent', None)
logger_name = data.pop('logger', None)
server_name = data.pop('server_name', None)
site = data.pop('site', None)
checksum = data.pop('checksum', None)
fingerprint = data.pop('fingerprint', None)
platform = data.pop('platform', None)
release = data.pop('release', None)
environment = data.pop('environment', None)
if not culprit:
culprit = generate_culprit(data)
date = datetime.fromtimestamp(data.pop('timestamp'))
date = date.replace(tzinfo=timezone.utc)
kwargs = {
'message': message,
'platform': platform,
}
event = Event(
project=project,
event_id=event_id,
data=data,
time_spent=time_spent,
datetime=date,
**kwargs
)
tags = data.get('tags') or []
tags.append(('level', LOG_LEVELS[level]))
if logger_name:
tags.append(('logger', logger_name))
if server_name:
tags.append(('server_name', server_name))
if site:
tags.append(('site', site))
if release:
# TODO(dcramer): we should ensure we create Release objects
tags.append(('sentry:release', release))
if environment:
tags.append(('environment', environment))
for plugin in plugins.for_project(project, version=None):
added_tags = safe_execute(plugin.get_tags, event,
_with_transaction=False)
if added_tags:
tags.extend(added_tags)
event_user = self._get_event_user(project, data)
if event_user:
tags.append(('sentry:user', event_user.tag_value))
# XXX(dcramer): we're relying on mutation of the data object to ensure
# this propagates into Event
data['tags'] = tags
data['fingerprint'] = fingerprint or '{{ default }}'
# prioritize fingerprint over checksum as its likely the client defaulted
# a checksum whereas the fingerprint was explicit
if fingerprint:
hashes = map(md5_from_hash, get_hashes_from_fingerprint(event, fingerprint))
elif checksum:
hashes = [checksum]
else:
hashes = map(md5_from_hash, get_hashes_for_event(event))
group_kwargs = kwargs.copy()
group_kwargs.update({
'culprit': culprit,
'logger': logger_name,
'level': level,
'last_seen': date,
'first_seen': date,
'time_spent_total': time_spent or 0,
'time_spent_count': time_spent and 1 or 0,
})
if release:
release = Release.get_or_create(
project=project,
version=release,
date_added=date,
)
group_kwargs['first_release'] = release
#.........这里部分代码省略.........