pyztk/test.py

37 lines
1.1 KiB
Python
Raw Normal View History

2016-05-23 13:50:54 +07:00
# -*- coding: utf-8 -*-
import sys
2018-05-04 02:58:52 +07:00
sys.path.append("zk")
2016-05-23 13:50:54 +07:00
2016-06-24 19:00:55 +07:00
from zk import ZK, const
conn = None
2018-04-30 20:33:17 +07:00
zk = ZK('192.168.1.201', port=4370, timeout=5)
2016-05-30 09:59:39 +07:00
try:
2018-05-04 02:58:52 +07:00
print ('Connecting to device ...')
2016-05-30 09:59:39 +07:00
conn = zk.connect()
2018-05-04 02:58:52 +07:00
print ('Disabling device ...')
2016-06-24 19:00:55 +07:00
conn.disable_device()
2018-05-04 02:58:52 +07:00
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'
2018-05-04 02:58:52 +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))
2016-05-25 16:28:55 +07:00
2018-05-04 02:58:52 +07:00
print ("Voice Test ...")
2016-06-24 19:00:55 +07:00
conn.test_voice()
2018-05-04 02:58:52 +07:00
print ('Enabling device ...')
2016-06-24 19:00:55 +07:00
conn.enable_device()
2018-05-04 02:58:52 +07:00
except Exception as e:
print ("Process terminate : {}".format(e))
2016-05-30 09:59:39 +07:00
finally:
if conn:
2016-06-24 19:00:55 +07:00
conn.disconnect()