lib/hid: Work around HID bug in returned XML records

Includes:
- lib/hid: Don't send recordCount as -1, fixes #4
This commit is contained in:
Adam Goldsmith 2020-02-21 16:19:46 -05:00
parent 9d743344ab
commit 641b9a2779

View File

@ -135,17 +135,24 @@ class DoorController():
recordCount = 0 recordCount = 0
moreRecords = True moreRecords = True
# note: all the "+/-1" bits are to work around a bug where the
# last returned entry is incomplete. There is probably a
# better way to do this, but for now I just get the last entry
# again in the next request. I suspect this probably ends
# poorly if the numbers line up poorly (ie an exact multiple
# of the returned record limit)
while moreRecords: while moreRecords:
res = self.doXMLRequest(ROOT( res = self.doXMLRequest(ROOT(
req({ req({
"action": "LR", "action": "LR",
"recordCount": str(count - recordCount), "recordCount": str(count - recordCount + 1),
"recordOffset": str(recordCount), "recordOffset": str(recordCount - 1
if recordCount > 0 else 0),
**params **params
}))) })))
result += list(res[0]) result = result[:-1] + list(res[0])
recordCount += int(res[0].get('recordCount')) recordCount += int(res[0].get('recordCount')) - 1
moreRecords = res[0].get('moreRecords') == 'true' moreRecords = res[0].get('moreRecords') == 'true'
return result return result