2016-05-23 13:50:54 +07:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
import sys
|
|
|
|
sys.path.append("zk")
|
|
|
|
|
|
|
|
import zk
|
2016-05-26 13:06:33 +07:00
|
|
|
from zk import const
|
2016-05-23 13:50:54 +07:00
|
|
|
|
2016-05-26 23:58:48 +07:00
|
|
|
zk = zk.ZK('192.168.1.201', port=4370, timeout=5)
|
2016-05-23 23:59:43 +07:00
|
|
|
print 'Connecting to device ...'
|
|
|
|
conn = zk.connect()
|
|
|
|
if conn.get('status'):
|
|
|
|
print conn
|
2016-05-25 16:28:55 +07:00
|
|
|
print 'Disabling device ...'
|
2016-05-24 21:49:04 +07:00
|
|
|
print zk.disable_device()
|
2016-05-23 14:41:39 +07:00
|
|
|
print 'Firmware Version: : {}'.format(zk.get_firmware_version())
|
2016-05-25 12:38:11 +07:00
|
|
|
# Load test create 2000 users
|
2016-05-25 15:35:45 +07:00
|
|
|
# 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='12345678', group_id='', user_id='{}'.format(i))
|
2016-05-25 16:28:55 +07:00
|
|
|
print '--- Get User ---'
|
|
|
|
users = zk.get_users()
|
|
|
|
if users.get('status'):
|
|
|
|
for user in users.get('data'):
|
|
|
|
privilege = 'User'
|
|
|
|
if user.privilege == const.USER_ADMIN:
|
|
|
|
privilege = 'Admin'
|
|
|
|
|
|
|
|
print '- UID #{}'.format(user.uid)
|
|
|
|
print ' Name : {}'.format(user.name)
|
|
|
|
print ' Privilege : {}'.format(privilege)
|
|
|
|
print ' Password : {}'.format(user.password)
|
|
|
|
print ' Group ID : {}'.format(user.group_id)
|
|
|
|
print ' User ID : {}'.format(user.user_id)
|
2016-05-23 19:49:36 +07:00
|
|
|
|
2016-05-25 16:28:55 +07:00
|
|
|
print "Voice Test ..."
|
2016-05-24 21:52:42 +07:00
|
|
|
print zk.test_voice()
|
2016-05-25 16:28:55 +07:00
|
|
|
# print 'Restarting device ...'
|
|
|
|
# print zk.restart()
|
|
|
|
# print 'Turning off device ...'
|
|
|
|
# print zk.power_off()
|
|
|
|
print 'Enabling device ...'
|
2016-05-24 21:49:04 +07:00
|
|
|
print zk.enable_device()
|
2016-05-25 16:28:55 +07:00
|
|
|
print 'Disconnecting to device ...'
|
2016-05-23 14:41:39 +07:00
|
|
|
print zk.disconnect()
|
|
|
|
else:
|
2016-05-23 23:59:43 +07:00
|
|
|
print 'Connecting Error: {}'.format(conn.get('message'))
|
|
|
|
|