Files
MesinAbsen/pyzkTest.py
Aries Wibowo 484ba05a65 Initial test
2026-04-22 09:19:12 +07:00

37 lines
1.2 KiB
Python

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()