From fc29f1a2e6c9cbeeba1542711d8e41413c378d39 Mon Sep 17 00:00:00 2001 From: Adam Goldsmith Date: Mon, 14 May 2018 22:41:10 -0400 Subject: [PATCH] events: rename input/output XMLs for easier reading --- events.py | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/events.py b/events.py index 603c031..1179b53 100755 --- a/events.py +++ b/events.py @@ -49,19 +49,22 @@ eventStrings = { # -XML = ET.Element("VertXMessage") -ET.SubElement(XML, "hid:EventMessages", attrib={"action": "LR"}) -xml = doXMLRequest(TARGET_IP, ET.tostring(XML)) -print(xml[0].attrib) +# get parameters for messages to get? +# honestly not really sure why this is required, their API is confusing +parXMLIn = ET.Element("VertXMessage") +ET.SubElement(parXMLIn, "hid:EventMessages", attrib={"action": "LR"}) +parXMLOut = doXMLRequest(TARGET_IP, ET.tostring(parXMLIn)) -XML = ET.Element("VertXMessage") -ET.SubElement(XML, "hid:EventMessages", +# get the actual messages +eventsXMLIn = ET.Element("VertXMessage") +ET.SubElement(eventsXMLIn, "hid:EventMessages", attrib={"action": "LR", "recordCount": "1000", - "historyRecordMarker": xml[0].attrib["historyRecordMarker"], - "historyTimestamp": xml[0].attrib["historyTimestamp"]}) -xml = doXMLRequest(TARGET_IP, ET.tostring(XML)) -for event in xml[0]: + "historyRecordMarker": parXMLOut[0].attrib["historyRecordMarker"], + "historyTimestamp": parXMLOut[0].attrib["historyTimestamp"]}) +eventsXMLOut = doXMLRequest(TARGET_IP, ET.tostring(eventsXMLIn)) + +for event in eventsXMLOut[0]: ET.dump(event) att = event.attrib eventType = int(att["eventType"])