Beispiel #1
0
def archive_voevent(v, rootdir):
    relpath, filename = v.attrib['ivorn'].split('//')[1].split('#')
    filename += ".xml"
    fullpath = os.path.sep.join((rootdir, relpath, filename))
    ps.utils.ensure_dir(fullpath)
    with open(fullpath, 'w') as f:
        voeparse.dump(v, f)
Beispiel #2
0
def dummy_send_to_comet_stub(voevent, host='localhost', port=8098):
    tf = tempfile.NamedTemporaryFile(delete=False)
    print textwrap.dedent("""\
    *************
     Would have sent a VOEvent to node: {host}:{port};
    Copy of XML dumped to: {fname}
    *************
    """.format(host=host, port=port, fname=tf.name))
    voeparse.dump(voevent, tf)
    tf.close()
Beispiel #3
0
def send_voevent(voevent, host='localhost', port=8098):
    tf = tempfile.TemporaryFile()
    voeparse.dump(voevent, tf)
    tf.seek(0)
    # tf.close()
    try:
        cmd = ['comet-sendvo']
        cmd.append('--host=' + host)
        cmd.append('--port=' + str(port))
        subprocess.check_call(cmd, stdin=tf)
    except subprocess.CalledProcessError as e:
        logger.error("send_voevent failed")
        raise e
Beispiel #4
0
    def test_initial_case(self):
        with open(datapaths.swift_bat_grb_pos_v2) as f:
            swift_alert = BatGrb(vp.load(f))

        request_status = {'sent_time':datetime.datetime.utcnow(),
                          'acknowledged':False,
                          }

        v = vo_subs.create_ami_followup_notification(swift_alert,
                                                 stream_id=001,
                                                 request_status=request_status)
        vp.assert_valid_as_v2_0(v)
        with open('/tmp/test_voevent.xml', 'w') as f:
            vp.dump(v, f)
def main(dbname, transient_id, voe_stream_id, output_filename):
    db = DataBase(name=dbname, user=dbname, password=dbname)
    transient = get_transient_info(db, transient_id)
    print "**********************************"
    print "Extracted the following transient details:"
    pp = pprint.PrettyPrinter()
    pp.pprint(transient)
    print "**********************************"
    print "Will generate VOEvent with following sender attributes:"
    pp.pprint(sender_attributes)
    print "**********************************"

    event = generate_voevent(transient, sender_attributes, voe_stream_id, role)

    print "Here's the raw xml:\n\n"
    print vp.dumps(event)
    print "\n\n"

    with open(output_filename, 'w') as f:
        vp.dump(event, f)

    return 0