update test file and fixing set_user password bug

This commit is contained in:
Fanani M. Ihsan 2016-05-25 12:38:11 +07:00
parent bd6554f88d
commit 619aaf1f43
2 changed files with 8 additions and 4 deletions

10
test.py
View File

@ -1,5 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import sys import sys
from zk import const
sys.path.append("zk") sys.path.append("zk")
import zk import zk
@ -11,9 +12,12 @@ if conn.get('status'):
print conn print conn
print zk.disable_device() print zk.disable_device()
print 'Firmware Version: : {}'.format(zk.get_firmware_version()) print 'Firmware Version: : {}'.format(zk.get_firmware_version())
# Load test create 1000 users # Load test create 2000 users
for i in range(1, 1000+1): for i in range(1, 2000+1):
zk.set_user(uid=i, user_id='{}'.format(i), name='user #{}'.format(i), password='123456', privilege=14) privilege = const.USER_DEFAULT
if i == 1:
privilege = const.USER_ADMIN
print zk.set_user(uid=i, name='user #{}'.format(i), privilege=privilege, password='123456', group_id='', user_id='{}'.format(i))
# print 'Restarting device' # print 'Restarting device'
# print zk.restart() # print zk.restart()
# print 'Turning off device' # print 'Turning off device'

View File

@ -210,7 +210,7 @@ class ZK(object):
privilege = const.USER_DEFAULT privilege = const.USER_DEFAULT
privilege = chr(privilege) privilege = chr(privilege)
command_string = pack('2sc6s30sc7sx24s', uid, privilege, password, name, chr(0), group_id, user_id) command_string = pack('2sc8s28sc7sx24s', uid, privilege, password, name, chr(0), group_id, user_id)
cmd_response = self.__send_command(command=command, command_string=command_string, response_size=1024) cmd_response = self.__send_command(command=command, command_string=command_string, response_size=1024)
cmd_response['data'] = '' cmd_response['data'] = ''
if cmd_response.get('status'): if cmd_response.get('status'):