# Path: kael/producer.py
# class Producer(MQ):
#     def __init__(self, name, auri, channel="center"):
#         super(Producer, self).__init__(channel=channel, extype="topic", auri=auri)
#         self.id = "producer-{0}_{1}".format(name, str(uuid4()))
#         self.schema = {}
# 
#     def pub(self, topic, data, schema_type=None, ttl=0):
#         schema = self.schema.get(topic, {}).get(schema_type, {})
#         if schema:
#             try:
#                 jsonschema.validate(data, schema, format_checker=formatchecker, )
#             except Exception, e:
#                 print "format erro", e
#                 return
#             data = {"schema": schema, "data": data}
#             self.push_msg(self.id, topic, data, ttl=ttl)
# 
#     def load_schema(self, file_path):
#         f = open(file_path, "r")
#         schema = yaml.load(f)
#         f.close()
#         self.schema.update(schema)


from kael.producer import Producer
import os
# -*- coding: utf-8 -*-


AMQ_URI = os.environ.get('AMQ_URI')


def main():
    P = Producer("test", auri=AMQ_URI, )
    P.load_schema("forms.yml")
    data = {"event": "dasdad", "ip": "12.13.12.1", "timestamp": "2013-03-25 21:39:35"}
    P.pub("honey.ioc", data, schema_type="scan_ip")



# Path: kael/producer.py
# class Producer(MQ):
#     def __init__(self, name, auri, channel="center"):
#         super(Producer, self).__init__(channel=channel, extype="topic", auri=auri)
#         self.id = "producer-{0}_{1}".format(name, str(uuid4()))
#         self.schema = {}
# 
#     def pub(self, topic, data, schema_type=None, ttl=0):
#         schema = self.schema.get(topic, {}).get(schema_type, {})
#         if schema:
#             try:
#                 jsonschema.validate(data, schema, format_checker=formatchecker, )
#             except Exception, e:
#                 print "format erro", e
#                 return
#             data = {"schema": schema, "data": data}
#             self.push_msg(self.id, topic, data, ttl=ttl)
# 
#     def load_schema(self, file_path):
#         f = open(file_path, "r")
#         schema = yaml.load(f)
#         f.close()
#         self.schema.update(schema)


# Path: examples/producer/test_c.py
from kael.producer import Producer
import os

# -*- coding: utf-8 -*-


AMQ_URI = os.environ.get('AMQ_URI')


def main():
    P = Producer("test", auri=AMQ_URI, )
    P.load_schema("forms.yml")
    data = {"event": "dasdad", "ip": "12.13.12.1", "timestamp": "2013-03-25 21:39:35"}
    P.pub("honey.ioc", data, schema_type="scan_ip")



if __name__ == '__main__':