本文整理汇总了Python中sentry.utils.samples.load_data函数的典型用法代码示例。如果您正苦于以下问题:Python load_data函数的具体用法?Python load_data怎么用?Python load_data使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了load_data函数的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: new_event
def new_event(request):
org = Organization(
id=1,
slug='example',
name='Example',
)
team = Team(
id=1,
slug='example',
name='Example',
organization=org,
)
project = Project(
id=1,
slug='example',
name='Example',
team=team,
organization=org,
)
group = Group(
id=1,
project=project,
message='This is an example event.',
level=logging.ERROR,
)
event = Event(
id=1,
project=project,
group=group,
message=group.message,
data=load_data('python'),
)
rule = Rule(label="An example rule")
interface_list = []
for interface in event.interfaces.itervalues():
body = interface.to_email_html(event)
if not body:
continue
interface_list.append((interface.get_title(), mark_safe(body)))
preview = MailPreview(
html_template='sentry/emails/error.html',
text_template='sentry/emails/error.html',
context={
'rule': rule,
'group': group,
'event': event,
'link': 'http://example.com/link',
'interfaces': interface_list,
'tags': event.get_tags(),
'project_label': project.name,
},
)
return render_to_response('sentry/debug/mail/preview.html', {
'preview': preview,
})
开发者ID:carriercomm,项目名称:sentry-1,代码行数:60,代码来源:mail.py
示例2: test_one_issue
def test_one_issue(self):
with self.feature('organizations:sentry10'):
self.init_snuba()
event_data = load_data('python')
event_data['event_id'] = 'd964fdbd649a4cf8bfc35d18082b6b0e'
event_data['timestamp'] = 1452683305
event = self.store_event(
project_id=self.project.id,
data=event_data,
assert_no_errors=False
)
event.group.update(
first_seen=datetime(2018, 1, 12, 3, 8, 25, tzinfo=timezone.utc),
last_seen=datetime(2018, 1, 13, 3, 8, 25, tzinfo=timezone.utc),
)
GroupAssignee.objects.create(
user=self.user,
group=event.group,
project=self.project,
)
OrganizationOnboardingTask.objects.create_or_update(
organization_id=self.project.organization_id,
task=OnboardingTask.FIRST_EVENT,
status=OnboardingTaskStatus.COMPLETE,
)
self.project.update(first_event=timezone.now())
self.browser.get(self.path)
self.browser.wait_until_not('.loading-indicator')
self.browser.wait_until('[data-test-id] figure')
self.browser.snapshot('org dash one issue')
开发者ID:yaoqi,项目名称:sentry,代码行数:31,代码来源:test_dashboard.py
示例3: get
def get(self, request):
org = Organization(
id=1,
slug='organization',
name='My Company',
)
project = Project(
id=1,
organization=org,
slug='project',
name='My Project',
)
group = next(
make_group_generator(
get_random(request),
project,
),
)
data = dict(load_data('python'))
data['message'] = group.message
data.pop('logentry', None)
event_manager = EventManager(data)
event_manager.normalize()
data = event_manager.get_data()
event_type = event_manager.get_event_type()
group.message = event_manager.get_search_message()
group.data = {
'type': event_type.key,
'metadata': event_type.get_metadata(data),
}
event = Event(
id=1,
project=project,
message=event_manager.get_search_message(),
group=group,
datetime=datetime(2016, 6, 13, 3, 8, 24, tzinfo=timezone.utc),
data=event_manager.get_data()
)
activity = Activity(
group=event.group, project=event.project, **self.get_activity(request, event)
)
return render_to_response(
'sentry/debug/mail/preview.html', {
'preview': ActivityMailPreview(request, activity),
'format': request.GET.get('format'),
}
)
开发者ID:yaoqi,项目名称:sentry,代码行数:54,代码来源:mail.py
示例4: new_note
def new_note(request):
org = Organization(
id=1,
slug='example',
name='Example',
)
team = Team(
id=1,
slug='example',
name='Example',
organization=org,
)
project = Project(
id=1,
slug='example',
name='Example',
team=team,
organization=org,
)
group = Group(
id=1,
project=project,
message='This is an example event.',
)
event = Event(
id=1,
project=project,
group=group,
message=group.message,
data=load_data('python'),
)
note = Activity(
group=event.group, event=event, project=event.project,
type=Activity.NOTE, user=request.user,
data={'text': 'This is an example note!'},
)
preview = MailPreview(
html_template='sentry/emails/activity/note.html',
text_template='sentry/emails/activity/note.txt',
context={
'data': note.data,
'author': note.user,
'date': note.datetime,
'group': group,
'link': group.get_absolute_url(),
},
)
return render_to_response('sentry/debug/mail/preview.html', {
'preview': preview,
})
开发者ID:carriercomm,项目名称:sentry-1,代码行数:52,代码来源:mail.py
示例5: assigned
def assigned(request):
org = Organization(
id=1,
slug='example',
name='Example',
)
team = Team(
id=1,
slug='example',
name='Example',
organization=org,
)
project = Project(
id=1,
slug='example',
name='Example',
team=team,
organization=org,
)
group = Group(
id=1,
project=project,
message='This is an example event.',
)
event = Event(
id=1,
project=project,
group=group,
message=group.message,
data=load_data('python'),
)
assigned = Activity(
group=event.group, event=event, project=event.project,
type=Activity.ASSIGNED, user=request.user,
data={'text': 'This is an example note!'},
)
return MailPreview(
html_template='sentry/emails/activity/assigned.html',
text_template='sentry/emails/activity/assigned.txt',
context={
'data': assigned.data,
'author': assigned.user,
'date': assigned.datetime,
'group': group,
'link': group.get_absolute_url(),
},
).render()
开发者ID:280185386,项目名称:sentry,代码行数:49,代码来源:mail.py
示例6: create_sample_event
def create_sample_event(self, platform, default=None, sample_name=None):
event_data = load_data(platform, default=default, sample_name=sample_name)
event_data['event_id'] = 'd964fdbd649a4cf8bfc35d18082b6b0e'
event = self.store_event(
data=event_data,
project_id=self.project.id,
assert_no_errors=False,
)
event.datetime = datetime(2017, 9, 6, 0, 0)
event.save()
event.group.update(
first_seen=datetime(2015, 8, 13, 3, 8, 25, tzinfo=timezone.utc),
last_seen=datetime(2016, 1, 13, 3, 8, 25, tzinfo=timezone.utc),
)
return event
开发者ID:yaoqi,项目名称:sentry,代码行数:15,代码来源:test_issue_details.py
示例7: get
def get(self, request):
org = Organization(
id=1,
slug='organization',
name='My Company',
)
team = Team(
id=1,
slug='team',
name='My Team',
organization=org,
)
project = Project(
id=1,
organization=org,
team=team,
slug='project',
name='My Project',
)
group = next(
make_group_generator(
get_random(request),
project,
),
)
event = Event(
id=1,
project=project,
group=group,
message=group.message,
data=load_data('python'),
datetime=datetime(2016, 6, 13, 3, 8, 24, tzinfo=timezone.utc),
)
activity = Activity(
group=event.group, project=event.project, **self.get_activity(request, event)
)
return render_to_response(
'sentry/debug/mail/preview.html', {
'preview': ActivityMailPreview(request, activity),
'format': request.GET.get('format'),
}
)
开发者ID:NuttasitBoonwat,项目名称:sentry,代码行数:46,代码来源:mail.py
示例8: digest
def digest(request):
seed = request.GET.get('seed', str(time.time()))
logger.debug('Using random seed value: %s')
random = Random(seed)
now = datetime.utcnow().replace(tzinfo=pytz.utc)
# TODO: Refactor all of these into something more manageable.
org = Organization(
id=1,
slug='example',
name='Example Organization',
)
team = Team(
id=1,
slug='example',
name='Example Team',
organization=org,
)
project = Project(
id=1,
slug='example',
name='Example Project',
team=team,
organization=org,
)
rules = {i: Rule(
id=i,
project=project,
label="Rule #%s" % (i,),
) for i in xrange(1, random.randint(2, 4))}
state = {
'project': project,
'groups': {},
'rules': rules,
'event_counts': {},
'user_counts': {},
}
records = []
group_sequence = itertools.count(1)
event_sequence = itertools.count(1)
for i in xrange(random.randint(1, 30)):
group_id = next(group_sequence)
group = state['groups'][group_id] = Group(
id=group_id,
project=project,
message='This is example event #%s' % (group_id,),
culprit='widget.foo in bar',
)
offset = timedelta(seconds=0)
for i in xrange(random.randint(1, 10)):
offset += timedelta(seconds=random.random() * 120)
event = Event(
id=next(event_sequence),
event_id=uuid.uuid4().hex,
project=project,
group=group,
message=group.message,
data=load_data('python'),
datetime=now - offset,
)
records.append(
Record(
event.event_id,
Notification(
event,
random.sample(state['rules'], random.randint(1, len(state['rules']))),
),
to_timestamp(event.datetime),
)
)
state['event_counts'][group_id] = random.randint(10, 1e4)
state['user_counts'][group_id] = random.randint(10, 1e4)
digest = build_digest(project, records, state)
# TODO(tkaemming): This duplication from ``MailPlugin.notify_digest`` is a code smell
counts = Counter()
for rule, groups in digest.iteritems():
counts.update(groups.keys())
return MailPreview(
html_template='sentry/emails/digests/body.html',
text_template='sentry/emails/digests/body.txt',
context={
'project': project,
'counts': counts,
'digest': digest,
},
#.........这里部分代码省略.........
开发者ID:zooming-tan,项目名称:sentry,代码行数:101,代码来源:mail.py
示例9: digest
def digest(request):
seed = request.GET.get('seed', str(time.time()))
logger.debug('Using random seed value: %s')
random = Random(seed)
now = datetime.utcnow().replace(tzinfo=pytz.utc)
# TODO: Refactor all of these into something more manageable.
org = Organization(
id=1,
slug='example',
name='Example Organization',
)
team = Team(
id=1,
slug='example',
name='Example Team',
organization=org,
)
project = Project(
id=1,
slug='example',
name='Example Project',
team=team,
organization=org,
)
rules = {i: Rule(
id=i,
project=project,
label="Rule #%s" % (i,),
) for i in xrange(1, random.randint(2, 4))}
state = {
'project': project,
'groups': {},
'rules': rules,
'event_counts': {},
'user_counts': {},
}
records = []
group_sequence = itertools.count(1)
event_sequence = itertools.count(1)
for i in xrange(random.randint(1, 30)):
group_id = next(group_sequence)
culprit = '{module} in {function}'.format(
module='.'.join(
''.join(random.sample(WORDS, random.randint(1, int(random.paretovariate(2.2))))) for word in xrange(1, 4)
),
function=random.choice(WORDS)
)
group = state['groups'][group_id] = Group(
id=group_id,
project=project,
message=words(int(random.weibullvariate(8, 4)), common=False),
culprit=culprit,
level=random.choice(LOG_LEVELS.keys()),
)
offset = timedelta(seconds=0)
for i in xrange(random.randint(1, 10)):
offset += timedelta(seconds=random.random() * 120)
event = Event(
id=next(event_sequence),
event_id=uuid.uuid4().hex,
project=project,
group=group,
message=group.message,
data=load_data('python'),
datetime=now - offset,
)
records.append(
Record(
event.event_id,
Notification(
event,
random.sample(state['rules'], random.randint(1, len(state['rules']))),
),
to_timestamp(event.datetime),
)
)
state['event_counts'][group_id] = random.randint(10, 1e4)
state['user_counts'][group_id] = random.randint(10, 1e4)
digest = build_digest(project, records, state)
start, end, counts = get_digest_metadata(digest)
return MailPreview(
html_template='sentry/emails/digests/body.html',
text_template='sentry/emails/digests/body.txt',
context={
'project': project,
#.........这里部分代码省略.........
开发者ID:280185386,项目名称:sentry,代码行数:101,代码来源:mail.py
示例10: new_event
def new_event(request):
platform = request.GET.get('platform', 'python')
org = Organization(
id=1,
slug='example',
name='Example',
)
team = Team(
id=1,
slug='example',
name='Example',
organization=org,
)
project = Project(
id=1,
slug='example',
name='Example',
team=team,
organization=org,
)
group = Group(
id=1,
project=project,
message='This is an example event.',
level=logging.ERROR,
)
event = Event(
id=1,
project=project,
group=group,
message=group.message,
data=load_data(platform),
)
rule = Rule(label="An example rule")
interface_list = []
for interface in event.interfaces.itervalues():
body = interface.to_email_html(event)
if not body:
continue
interface_list.append((interface.get_title(), mark_safe(body)))
return MailPreview(
html_template='sentry/emails/error.html',
text_template='sentry/emails/error.html',
context={
'rule': rule,
'group': group,
'event': event,
'link': 'http://example.com/link',
'interfaces': interface_list,
'tags': event.get_tags(),
'project_label': project.name,
'tags': [
('logger', 'javascript'),
('environment', 'prod'),
('level', 'error'),
('device', 'Other')
]
},
).render()
开发者ID:Akashguharoy,项目名称:sentry,代码行数:63,代码来源:mail.py
示例11: digest
def digest(request):
seed = request.GET.get('seed', str(time.time()))
logger.debug('Using random seed value: %s')
random = Random(seed)
now = datetime.utcnow().replace(tzinfo=pytz.utc)
# TODO: Refactor all of these into something more manageable.
org = Organization(
id=1,
slug='example',
name='Example Organization',
)
team = Team(
id=1,
slug='example',
name='Example Team',
organization=org,
)
project = Project(
id=1,
slug='example',
name='Example Project',
team=team,
organization=org,
)
state = {
'project': project,
'groups': {},
'rules': {
1: Rule(id=1, project=project, label="First Rule"),
2: Rule(id=2, project=project, label="Second Rule"),
3: Rule(id=3, project=project, label="Third Rule"),
},
'event_counts': {},
'user_counts': {},
}
records = []
group_sequence = itertools.count(1)
event_sequence = itertools.count(1)
for i in xrange(random.randint(1, 4)):
group_id = next(group_sequence)
group = state['groups'][group_id] = Group(
id=group_id,
project=project,
message='This is example event #%s' % (group_id,),
)
offset = timedelta(seconds=0)
for i in xrange(random.randint(1, 10)):
offset += timedelta(seconds=random.random() * 120)
event = Event(
id=next(event_sequence),
event_id=uuid.uuid4().hex,
project=project,
group=group,
message=group.message,
data=load_data('python'),
datetime=now - offset,
)
records.append(
Record(
event.event_id,
Notification(
event,
random.sample(state['rules'], random.randint(1, len(state['rules']))),
),
to_timestamp(event.datetime),
)
)
state['event_counts'][group_id] = random.randint(10, 1e4)
state['user_counts'][group_id] = random.randint(10, 1e4)
digest = build_digest(project, records, state)
return MailPreview(
html_template='sentry/emails/digests/body.html',
text_template='sentry/emails/digests/body.txt',
context={
'project': project,
'digest': digest,
},
).render()
开发者ID:noah-lee,项目名称:sentry,代码行数:92,代码来源:mail.py
示例12: digest
def digest(request):
random = get_random(request)
# TODO: Refactor all of these into something more manageable.
org = Organization(
id=1,
slug='example',
name='Example Organization',
)
team = Team(
id=1,
slug='example',
name='Example Team',
organization=org,
)
project = Project(
id=1,
slug='example',
name='Example Project',
team=team,
organization=org,
)
rules = {i: Rule(
id=i,
project=project,
label="Rule #%s" % (i,),
) for i in range(1, random.randint(2, 4))}
state = {
'project': project,
'groups': {},
'rules': rules,
'event_counts': {},
'user_counts': {},
}
records = []
event_sequence = itertools.count(1)
group_generator = make_group_generator(random, project)
for i in range(random.randint(1, 30)):
group = next(group_generator)
state['groups'][group.id] = group
offset = timedelta(seconds=0)
for i in range(random.randint(1, 10)):
offset += timedelta(seconds=random.random() * 120)
event = Event(
id=next(event_sequence),
event_id=uuid.uuid4().hex,
project=project,
group=group,
message=group.message,
data=load_data('python'),
datetime=to_datetime(
random.randint(
to_timestamp(group.first_seen),
to_timestamp(group.last_seen),
),
)
)
records.append(
Record(
event.event_id,
Notification(
event,
random.sample(state['rules'], random.randint(1, len(state['rules']))),
),
to_timestamp(event.datetime),
)
)
state['event_counts'][group.id] = random.randint(10, 1e4)
state['user_counts'][group.id] = random.randint(10, 1e4)
digest = build_digest(project, records, state)
start, end, counts = get_digest_metadata(digest)
context = {
'project': project,
'counts': counts,
'digest': digest,
'start': start,
'end': end,
}
add_unsubscribe_link(context)
return MailPreview(
html_template='sentry/emails/digests/body.html',
text_template='sentry/emails/digests/body.txt',
context=context,
).render(request)
开发者ID:faulkner,项目名称:sentry,代码行数:97,代码来源:mail.py
示例13: alert
def alert(request):
platform = request.GET.get('platform', 'python')
org = Organization(
id=1,
slug='example',
name='Example',
)
team = Team(
id=1,
slug='example',
name='Example',
organization=org,
)
project = Project(
id=1,
slug='example',
name='Example',
team=team,
organization=org,
)
random = get_random(request)
group = next(
make_group_generator(random, project),
)
event = Event(
id=1,
project=project,
group=group,
message=group.message,
data=load_data(platform),
datetime=to_datetime(
random.randint(
to_timestamp(group.first_seen),
to_timestamp(group.last_seen),
),
),
)
rule = Rule(label="An example rule")
interface_list = []
for interface in six.itervalues(event.interfaces):
body = interface.to_email_html(event)
if not body:
continue
interface_list.append((interface.get_title(), mark_safe(body)))
return MailPreview(
html_template='sentry/emails/error.html',
text_template='sentry/emails/error.txt',
context={
'rule': rule,
'group': group,
'event': event,
'link': 'http://example.com/link',
'interfaces': interface_list,
'tags': event.get_tags(),
'project_label': project.name,
'tags': [
('logger', 'javascript'),
('environment', 'prod'),
('level', 'error'),
('device', 'Other')
]
},
).render(request)
开发者ID:faulkner,项目名称:sentry,代码行数:68,代码来源:mail.py
示例14: alert
def alert(request):
platform = request.GET.get('platform', 'python')
org = Organization(
id=1,
slug='example',
name='Example',
)
project = Project(
id=1,
slug='example',
name='Example',
organization=org,
)
random = get_random(request)
group = next(
make_group_generator(random, project),
)
event = Event(
id=1,
event_id='44f1419e73884cd2b45c79918f4b6dc4',
project=project,
group=group,
message=group.message,
data=load_data(platform),
datetime=to_datetime(
random.randint(
to_timestamp(group.first_seen),
to_timestamp(group.last_seen),
),
),
)
rule = Rule(label="An example rule")
interface_list = []
for interface in six.itervalues(event.interfaces):
body = interface.to_email_html(event)
if not body:
continue
interface_list.append((interface.get_title(), mark_safe(body)))
return MailPreview(
html_template='sentry/emails/error.html',
text_template='sentry/emails/error.txt',
context={
'rule': rule,
'group': group,
'event': event,
'link': 'http://example.com/link',
'interfaces': interface_list,
'tags': event.get_tags(),
'project_label': project.slug,
'tags': [
('logger', 'javascript'), ('environment', 'prod'), ('level', 'error'),
('device', 'Other')
],
'commits': [{
# TODO(dcramer): change to use serializer
"repository": {"status": "active", "name": "Example Repo", "url": "https://github.com/example/example", "dateCreated": "2018-02-28T23:39:22.402Z", "provider": {"id": "github", "name": "GitHub"}, "id": "1"},
"score": 2,
"subject": "feat: Do something to raven/base.py",
"message": "feat: Do something to raven/base.py\naptent vivamus vehicula tempus volutpat hac tortor",
"id": "1b17483ffc4a10609e7921ee21a8567bfe0ed006",
"shortId": "1b17483",
"author": {"username": "[email protected]", "isManaged": False, "lastActive": "2018-03-01T18:25:28.149Z", "id": "1", "isActive": True, "has2fa": False, "name": "[email protected]", "avatarUrl": "https://secure.gravatar.com/avatar/51567a4f786cd8a2c41c513b592de9f9?s=32&d=mm", "dateJoined": "2018-02-27T22:04:32.847Z", "emails": [{"is_verified": False, "id": "1", "email": "[email protected]"}], "avatar": {"avatarUuid": None, "avatarType": "letter_avatar"}, "lastLogin": "2018-02-27T22:04:32.847Z", "email": "[email protected]"}
}],
},
).render(request)
开发者ID:hosmelq,项目名称:sentry,代码行数:70,代码来源:mail.py
注:本文中的sentry.utils.samples.load_data函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论