Esempio n. 1
0
def job_state_changed(job, result):
    # FIXME - Background job!
    try:
        state_change_notification(job, result)
    except Exception, ex:
        log.error('Could not send state-change notification mail',
                  exc_info=True)
Esempio n. 2
0
def test_state_change_notification():
    with patch('proccer.notifications.smtplib') as smtplib:
        smtp = smtplib.SMTP.return_value = Mock()
        with devops_mail_patch:
            state_change_notification(job, ok_result)
        assert smtplib.SMTP.call_args == (('no-such-host',), {}),\
               smtplib.SMTP.call_args
        assert smtp.sendmail.called
Esempio n. 3
0
def send_lateness_notifications(session):
    'Send warnings about any jobs that are late.'

    now = datetime.utcnow()
    late = (session
                .query(Job)
                .filter(Job.deleted == None)
                .filter(Job.last_seen + Job.warn_after < now)
                .filter(Job.state_id == job_state_id['ok']))

    for job in late:
        log.debug('late: %r', job)
        job.last_stamp = now
        job.state = 'late'
        state_change_notification(job, None)