38 lines
1013 B
Python
Executable File
38 lines
1013 B
Python
Executable File
#!/usr/bin/env python3
|
|
import requests
|
|
from xml.etree import ElementTree as ET
|
|
import csv
|
|
from io import StringIO
|
|
|
|
from common import *
|
|
|
|
TARGET_IP = '172.18.51.15'
|
|
|
|
def doRequest(xml):
|
|
r = requests.get(
|
|
'https://' + TARGET_IP + '/cgi-bin/vertx_xml.cgi',
|
|
params={'XML': xml},
|
|
auth=requests.auth.HTTPDigestAuth(DOOR_USERNAME, DOOR_PASSWORD),
|
|
verify=False)
|
|
print(r.text)
|
|
|
|
# clear all people
|
|
outString = StringIO()
|
|
writer = csv.DictWriter(outString, fieldnames)
|
|
writer.writeheader()
|
|
writer.writerow({})
|
|
outString.seek(0)
|
|
doCSVImport(TARGET_IP, outString)
|
|
|
|
# clear all schedules
|
|
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))
|
|
|
|
# load new schedules
|
|
with open("schedules.xml", "rb") as f:
|
|
doRequest(f.read())
|