From 619aaf1f431439684ae7fce45b699b6faff3d688 Mon Sep 17 00:00:00 2001 From: "Fanani M. Ihsan" Date: Wed, 25 May 2016 12:38:11 +0700 Subject: [PATCH] update test file and fixing set_user password bug --- test.py | 10 +++++++--- zk/base.py | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/test.py b/test.py index ff605b3..5c2aaa0 100644 --- a/test.py +++ b/test.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- import sys +from zk import const sys.path.append("zk") import zk @@ -11,9 +12,12 @@ if conn.get('status'): print conn print zk.disable_device() print 'Firmware Version: : {}'.format(zk.get_firmware_version()) - # Load test create 1000 users - for i in range(1, 1000+1): - zk.set_user(uid=i, user_id='{}'.format(i), name='user #{}'.format(i), password='123456', privilege=14) + # Load test create 2000 users + for i in range(1, 2000+1): + 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 zk.restart() # print 'Turning off device' diff --git a/zk/base.py b/zk/base.py index 0734f3c..cb8d75f 100644 --- a/zk/base.py +++ b/zk/base.py @@ -210,7 +210,7 @@ class ZK(object): privilege = const.USER_DEFAULT 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['data'] = '' if cmd_response.get('status'):