2016-05-23 13:50:54 +07:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
import sys
|
|
|
|
|
2016-06-24 19:00:55 +07:00
|
|
|
from zk import ZK, const
|
|
|
|
|
|
|
|
sys.path.append("zk")
|
2016-05-23 13:50:54 +07:00
|
|
|
|
2016-06-24 19:00:55 +07:00
|
|
|
conn = None
|
|
|
|
zk = ZK('192.168.1.10', port=4370, timeout=5)
|
2016-05-30 09:59:39 +07:00
|
|
|
try:
|
|
|
|
print 'Connecting to device ...'
|
|
|
|
conn = zk.connect()
|
2016-05-25 16:28:55 +07:00
|
|
|
print 'Disabling device ...'
|
2016-06-24 19:00:55 +07:00
|
|
|
conn.disable_device()
|
|
|
|
print 'Firmware Version: : {}'.format(conn.get_firmware_version())
|
2016-05-29 20:27:01 +07:00
|
|
|
# print '--- Get User ---'
|
2016-06-24 19:00:55 +07:00
|
|
|
users = conn.get_users()
|
2016-05-29 20:27:01 +07:00
|
|
|
for user in users:
|
|
|
|
privilege = 'User'
|
|
|
|
if user.privilege == const.USER_ADMIN:
|
|
|
|
privilege = 'Admin'
|
2016-05-25 16:28:55 +07:00
|
|
|
|
2016-05-29 20:27:01 +07:00
|
|
|
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)
|
2018-04-18 07:33:46 +07:00
|
|
|
print ' Card : {}'.format(user.card)
|
2016-05-23 19:49:36 +07:00
|
|
|
|
2016-05-25 16:28:55 +07:00
|
|
|
print "Voice Test ..."
|
2016-06-24 19:00:55 +07:00
|
|
|
conn.test_voice()
|
2016-05-25 16:28:55 +07:00
|
|
|
print 'Enabling device ...'
|
2016-06-24 19:00:55 +07:00
|
|
|
conn.enable_device()
|
2016-05-30 09:59:39 +07:00
|
|
|
except Exception, e:
|
|
|
|
print "Process terminate : {}".format(e)
|
|
|
|
finally:
|
|
|
|
if conn:
|
2016-06-24 19:00:55 +07:00
|
|
|
conn.disconnect()
|