startup.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:spikes 作者: mozilla 项目源码 文件源码
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)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号