minor fixes

This commit is contained in:
Arturo Hernandez 2018-04-18 20:22:03 -04:00
parent 5171917e60
commit a4405075f2
2 changed files with 10 additions and 7 deletions

View File

@ -533,8 +533,10 @@ class ZK(object):
return True
else:
raise ZKErrorResponse("Cant set user")
def save_user_template(self, user, fingers=[]):
""" save user and template """
#TODO: grabado global
# armar paquete de huellas
if isinstance(fingers, Finger):
fingers =[Finger]
@ -544,9 +546,8 @@ class ZK(object):
tstart = 0
for finger in fingers:
tfp = finger.repack_only()
table += pack("<bHbI", 2, user.uid, fnum, tstart)
table += pack("<bHbI", 2, user.uid, fnum + finger.fid, tstart)
tstart += len(tfp)
fnum += 1 # hack
fpack += tfp
upack = user.repack29()
head = pack("III", len(upack), len(table), len(fpack))
@ -868,12 +869,14 @@ class ZK(object):
print "enroll ok", size, pos
return True
def clear_data(self):
def clear_data(self, clear_type=5): # FCT_USER
'''
clear all data (include: user, attendance report, finger database )
2 = FCT_FINGERTMP
'''
command = const.CMD_CLEAR_DATA
cmd_response = self.__send_command(command)
command_string = pack("B", clear_type)
cmd_response = self.__send_command(command, command_string)
if cmd_response.get('status'):
return True
else:

View File

@ -4,9 +4,9 @@ class User(object):
def __init__(self, uid, name, privilege, password='', group_id='', user_id='', card=0):
self.uid = uid
self.name = name
self.name = str(name)
self.privilege = privilege
self.password = password
self.password = str(password)
self.group_id = group_id
self.user_id = user_id
self.card = card # 64 int to 40 bit int
@ -14,7 +14,7 @@ class User(object):
return pack("<BHB5s8s5sBhI", 2, self.uid, self.privilege, self.password, self.name, pack("Q", self.card), int(self.group_id), 0, int(self.user_id))
def __str__(self):
return '<User>: {}'.format(self.name)
return '<User>: [uid:{}, name:{} user_id:{}]'.format(self.uid, self.name, self.user_id)
def __repr__(self):
return '<User>: {}'.format(self.name)