Example #1
0
def generate_report_text(alert, sites, actions_taken,
                         report_timestamp=None):
    if report_timestamp is None:
        report_timestamp = datetime.datetime.now(pytz.utc)
    site_reports = [(site, get_ephem(alert.position, site, report_timestamp))
                            for site in sites]
    notification_template = env.get_template('notify.j2')
    msg_context=dict(alert=alert,
                report_timestamp=report_timestamp,
                site_reports=site_reports,
                actions_taken=actions_taken,)
    msg_context.update(ps.base_context())
    msg = notification_template.render(msg_context)
    return msg
Example #2
0
def test_logic(v):
    now = datetime.datetime.now(pytz.utc)
    stream_id = v.attrib['ivorn'].partition('#')[-1]
    response = ps.voevent.create_4pisky_test_response_voevent(
        stream_id=stream_id,
        date=now)

    ps.comms.comet.send_voevent(response, contacts.local_vobroker.ipaddress,
                                contacts.local_vobroker.port)
    testresponse_template = env.get_template('test_response.j2')
    msg_context = dict(now=now)
    msg_context.update(ps.base_context())
    msg = testresponse_template.render(msg_context)
    ps.comms.email.send_email(
        recipient_addresses=[c.email for c in contacts.test_contacts],
        subject=notification_email_prefix + '[TEST] Test packet received',
        body_text=msg)
    archive_voevent(v, rootdir=default_archive_root)