diff --git a/CoT.py b/CoT.py index cfe9dd3..e36ae73 100644 --- a/CoT.py +++ b/CoT.py @@ -33,9 +33,11 @@ DATETIME_FMT = "%Y-%m-%dT%H:%M:%SZ" + class CursorOnTarget: - def atoms(__self, unit): + @staticmethod + def atoms(unit): timer = dt.datetime now = timer.utcnow() zulu = now.strftime(DATETIME_FMT) @@ -60,6 +62,7 @@ def atoms(__self, unit): evt_attr = { "version": "2.0", "uid": cot_id, + "how": "m-g", "time": zulu, "start": zulu, "stale": stale, @@ -73,21 +76,24 @@ def atoms(__self, unit): "ce": "10", #unit["ce"], "le": "10" #unit["le"]1 } - + cot = ET.Element('event', attrib=evt_attr) ET.SubElement(cot, 'detail') - ET.SubElement(cot,'point', attrib=pt_attr) - - cot_xml = '' + ET.tostring(cot) + ET.SubElement(cot, 'point', attrib=pt_attr) + + cot_xml = '' + ET.tostring(cot, encoding='unicode') + return cot_xml - def pushUDP(__self, ip_address, port, cot_xml): + @staticmethod + def pushUDP(ip_address, port, cot_xml): sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) - sent = sock.sendto(cot_xml, (ip_address, port)) + sent = sock.sendto(bytes(cot_xml, 'utf-8'), (ip_address, port)) return sent - def pushTCP(__self, ip_address, port, cot_xml): + @staticmethod + def pushTCP(ip_address, port, cot_xml): sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) conn = sock.connect((ip_address, port)) - return sock.send(cot_xml) + return sock.send(bytes(cot_xml, 'utf-8')) diff --git a/README.md b/README.md index 46c437c..123860b 100644 --- a/README.md +++ b/README.md @@ -23,14 +23,15 @@ type is MIL-STD-2525 function code in CoT format (single letters separated by hy Sample output data: ``` - + + stale="2017-10-30T11:55:38.07Z" + type="a-h-G">