From 2ba766c1568209892ea9886afda8664201901329 Mon Sep 17 00:00:00 2001 From: "Fanani M. Ihsan" Date: Thu, 27 Dec 2018 17:13:03 +0700 Subject: [PATCH] fixes livecapture --- zk/base.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/zk/base.py b/zk/base.py index cf2b669..af4d0ad 100644 --- a/zk/base.py +++ b/zk/base.py @@ -1235,8 +1235,11 @@ class ZK(object): if not len(data): if self.verbose: print ("empty") continue - while len(data) >= 32: - if len(data) == 32: + while len(data) >= 12: + if len(data) == 12: + user_id, status, punch, timehex = unpack('= 52: user_id, status, punch, timehex, _other = unpack('<24sBB6s20s', data[:52]) data = data[52:] - user_id = (user_id.split(b'\x00')[0]).decode(errors='ignore') + if isinstance(user_id, int): + user_id = str(user_id) + else: + user_id = (user_id.split(b'\x00')[0]).decode(errors='ignore') timestamp = self.__decode_timehex(timehex) tuser = list(filter(lambda x: x.user_id == user_id, users)) if not tuser: