From ac482e8f0038e60aa62ea0c307475bf6e7087521 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Vinot?= Date: Sat, 12 Apr 2014 17:44:47 +0200 Subject: [PATCH] support xml and json copy --- pymisp/testing.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 pymisp/testing.py diff --git a/pymisp/testing.py b/pymisp/testing.py new file mode 100644 index 0000000..849ab16 --- /dev/null +++ b/pymisp/testing.py @@ -0,0 +1,31 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +from api import PyMISP + +from keys import src, dest + +url_source = 'https://misp.circl.lu' +url_dest = 'https://misppriv.circl.lu' +source = None +destination = None + +def init(): + global source + global destination + source = PyMISP(url_source, src, 'xml') + destination = PyMISP(url_dest, dest, 'xml') + +def copy_event(event_id): + r_src = source.get_event(event_id) + if 'json' in r_src.headers['content-type']: + to_send = r_src.json() + else: + to_send = r_src.text.encode('utf-8') + r_dst = destination.add_event(to_send) + #print r_dst.text + +if __name__ == '__main__': + init() + copy_event(0000) +