import sys import os from zk import ZK, const conn = None #create a ZK instance zk = ZK('192.168.1.24', port=4370, timeout=300, 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_attendance() for user in users: # privilege = 'User' # if user.privilege == const.USER_ADMIN: # privilege = 'Admin' print ('+ Marcacion #{}'.format(user)) # 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()