From 0d95865c8b30f1eef5aa4aa03fb0ddaf27b0d37a Mon Sep 17 00:00:00 2001 From: Adam Goldsmith Date: Sat, 12 May 2018 09:50:12 -0400 Subject: [PATCH] sendSchedule: Add clearing people DB allows updating doors fully automatically --- sendSchedule.py | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/sendSchedule.py b/sendSchedule.py index 28676ad..c2769e2 100755 --- a/sendSchedule.py +++ b/sendSchedule.py @@ -1,20 +1,30 @@ #!/usr/bin/env python3 import requests from xml.etree import ElementTree as ET -import urllib3 +import csv +from io import StringIO -from passwords import * +from common import * -urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) +TARGET_IP = '172.18.51.15' def doRequest(xml): r = requests.get( - 'https://172.18.51.15/cgi-bin/vertx_xml.cgi', + '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", @@ -22,5 +32,6 @@ for ii in range(1, 8): print(b'' + ET.tostring(delXML)) doRequest(b'' + ET.tostring(delXML)) +# load new schedules with open("schedules.xml", "rb") as f: doRequest(f.read())