Initial test
This commit is contained in:
37
pyzkTest.py
Normal file
37
pyzkTest.py
Normal file
@@ -0,0 +1,37 @@
|
||||
import sys
|
||||
import os
|
||||
sys.path.insert(1,os.path.abspath("./pyzk"))
|
||||
from zk import ZK, const
|
||||
|
||||
|
||||
conn = None
|
||||
# create ZK instance
|
||||
zk = ZK('10.35.7.12', port=4370, timeout=5, password=0, force_udp=False, ommit_ping=False)
|
||||
try:
|
||||
# connect to device
|
||||
conn = zk.connect()
|
||||
# disable device, this method ensures no activity on the device while the process is run
|
||||
conn.disable_device()
|
||||
# another commands will be here!
|
||||
# Example: Get All Users
|
||||
users = conn.get_users()
|
||||
for user in users:
|
||||
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))
|
||||
|
||||
# Test Voice: Say Thank You
|
||||
conn.test_voice()
|
||||
# re-enable device after all commands already executed
|
||||
conn.enable_device()
|
||||
except Exception as e:
|
||||
print ("Process terminate : {}".format(e))
|
||||
finally:
|
||||
if conn:
|
||||
conn.disconnect()
|
||||
Reference in New Issue
Block a user