def send_email(emails=[], date='today'):
significants, bugs_by_signature, totals = get(date=date)
r = prepare(significants, bugs_by_signature, totals, date)
if r:
results, spikes_number, urls, affected_chans, yesterday, today = r
env = Environment(loader=FileSystemLoader('templates'))
template = env.get_template('startup_crashes_email')
spikes_number_word = inflect.engine().number_to_words(spikes_number)
body = template.render(spikes_number=spikes_number,
spikes_number_word=spikes_number_word,
totals=totals,
start_date=yesterday,
end_date=today,
results=results,
urls=urls)
chan_list = ', '.join(affected_chans)
title = 'Spikes in startup crashes in {} the {}'
title = title.format(chan_list, today)
if emails:
mail.send(emails, title, body, html=True)
else:
with open('/tmp/foo.html', 'w') as Out:
Out.write(body)
print('Title: %s' % title)
print('Body:')
print(body)
评论列表
文章目录