2018-05-09 21:26:20 -04:00
|
|
|
#!/usr/bin/env python3
|
2018-05-07 18:04:12 -04:00
|
|
|
import requests
|
|
|
|
from xml.etree import ElementTree as ET
|
2018-05-12 09:50:12 -04:00
|
|
|
import csv
|
|
|
|
from io import StringIO
|
2018-05-07 18:04:12 -04:00
|
|
|
|
2018-05-12 09:50:12 -04:00
|
|
|
from common import *
|
2018-05-07 18:04:12 -04:00
|
|
|
|
2018-05-12 09:50:12 -04:00
|
|
|
TARGET_IP = '172.18.51.15'
|
2018-05-07 18:04:12 -04:00
|
|
|
|
|
|
|
def doRequest(xml):
|
|
|
|
r = requests.get(
|
2018-05-12 09:50:12 -04:00
|
|
|
'https://' + TARGET_IP + '/cgi-bin/vertx_xml.cgi',
|
2018-05-07 18:04:12 -04:00
|
|
|
params={'XML': xml},
|
|
|
|
auth=requests.auth.HTTPDigestAuth(DOOR_USERNAME, DOOR_PASSWORD),
|
|
|
|
verify=False)
|
|
|
|
print(r.text)
|
|
|
|
|
2018-05-12 09:50:12 -04:00
|
|
|
# clear all people
|
|
|
|
outString = StringIO()
|
|
|
|
writer = csv.DictWriter(outString, fieldnames)
|
|
|
|
writer.writeheader()
|
|
|
|
writer.writerow({})
|
|
|
|
outString.seek(0)
|
|
|
|
doCSVImport(TARGET_IP, outString)
|
|
|
|
|
|
|
|
# clear all schedules
|
2018-05-07 18:04:12 -04:00
|
|
|
delXML = ET.Element("VertXMessage")
|
|
|
|
for ii in range(1, 8):
|
|
|
|
ET.SubElement(delXML, "hid:Schedules",
|
|
|
|
attrib={"action": "DD", "scheduleID": str(ii)})
|
|
|
|
print(b'<?xml version="1.0" encoding="UTF-8"?>' + ET.tostring(delXML))
|
|
|
|
doRequest(b'<?xml version="1.0" encoding="UTF-8"?>' + ET.tostring(delXML))
|
|
|
|
|
2018-05-12 09:50:12 -04:00
|
|
|
# load new schedules
|
2018-05-07 18:04:12 -04:00
|
|
|
with open("schedules.xml", "rb") as f:
|
|
|
|
doRequest(f.read())
|