diff --git a/example/get_device_info.py b/example/get_device_info.py new file mode 100644 index 0000000..77c573c --- /dev/null +++ b/example/get_device_info.py @@ -0,0 +1,41 @@ +# -*- coding: utf-8 -*- +import os +import sys + +CWD = os.path.dirname(os.path.realpath(__file__)) +ROOT_DIR = os.path.dirname(CWD) +sys.path.append(ROOT_DIR) + +from zk import ZK, const + + +conn = None +zk = ZK('192.168.2.201', port=4370) +try: + conn = zk.connect() + print ("-- Device Information --") + print (" Current Time : %s" % conn.get_time()) + print (" Firmware Version : %s" % conn.get_firmware_version()) + print (" Device Name : %s" % conn.get_device_name()) + print (" Serial Number : %s" % conn.get_serialnumber()) + print (" Mac Address : %s" % conn.get_mac()) + print (" Face Algorithm Version : %s" % conn.get_face_version()) + print (" Finger Algorithm : %s" % conn.get_fp_version()) + print (" Platform Information : %s" % conn.get_platform()) + #print (conn.get_extend_fmt()) + #print (conn.get_user_extend_fmt()) + #print (conn.get_face_fun_on()) + #print (conn.get_compat_old_firmware()) + network_info = conn.get_network_params() + print ("-- Network Information") + print (" IP : %s" % network_info.get('ip')) + print (" Netmask : %s" % network_info.get('mask')) + print (" Gateway : %s" % network_info.get('gateway')) + #print (conn.get_pin_width()) + #print (conn.free_data()) + #print (conn.refresh_data()) +except Exception as e: + print ("Process terminate : {}".format(e)) +finally: + if conn: + conn.disconnect() diff --git a/example/get_memory_info.py b/example/get_memory_info.py new file mode 100644 index 0000000..5b8529a --- /dev/null +++ b/example/get_memory_info.py @@ -0,0 +1,30 @@ +# -*- coding: utf-8 -*- +import os +import sys + +CWD = os.path.dirname(os.path.realpath(__file__)) +ROOT_DIR = os.path.dirname(CWD) +sys.path.append(ROOT_DIR) + +from zk import ZK, const + + +conn = None +zk = ZK('192.168.2.201', port=4370) +try: + conn = zk.connect() + print ("-- Memory Information --") + conn.read_sizes() + print ("User (used/max) : %s/%s" % (conn.users, conn.users_cap)) + print ("Fingerprint (used/max) : %s/%s" % (conn.fingers, conn.fingers_cap)) + #print conn.dummy + #print conn.cards + #print conn.rec_cap + #print conn.fingers_av + #print conn.users_av + #print conn.rec_av +except Exception as e: + print ("Process terminate : {}".format(e)) +finally: + if conn: + conn.disconnect() diff --git a/example/get_users.py b/example/get_users.py new file mode 100644 index 0000000..10b3c0a --- /dev/null +++ b/example/get_users.py @@ -0,0 +1,39 @@ +# -*- coding: utf-8 -*- +import os +import sys + +CWD = os.path.dirname(os.path.realpath(__file__)) +ROOT_DIR = os.path.dirname(CWD) +sys.path.append(ROOT_DIR) + +from zk import ZK, const + + +conn = None +zk = ZK('192.168.2.201', port=4370) +try: + conn = zk.connect() + print ('Disabling device ...') + conn.disable_device() + print ('--- Get User ---') + 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)) + + print ("Voice Test ...") + conn.test_voice() + print ('Enabling device ...') + conn.enable_device() +except Exception as e: + print ("Process terminate : {}".format(e)) +finally: + if conn: + conn.disconnect() diff --git a/example/poweroff_device.py b/example/poweroff_device.py new file mode 100644 index 0000000..42c54a4 --- /dev/null +++ b/example/poweroff_device.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +import os +import sys + +CWD = os.path.dirname(os.path.realpath(__file__)) +ROOT_DIR = os.path.dirname(CWD) +sys.path.append(ROOT_DIR) + +from zk import ZK, const + + +conn = None +zk = ZK('192.168.2.201', port=4370) +try: + conn = zk.connect() + print ("Shutdown the device...") + conn.poweroff() +except Exception as e: + print ("Process terminate : {}".format(e)) +finally: + if conn: + conn.disconnect() diff --git a/example/restart_device.py b/example/restart_device.py new file mode 100644 index 0000000..8374fa6 --- /dev/null +++ b/example/restart_device.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +import os +import sys + +CWD = os.path.dirname(os.path.realpath(__file__)) +ROOT_DIR = os.path.dirname(CWD) +sys.path.append(ROOT_DIR) + +from zk import ZK, const + + +conn = None +zk = ZK('192.168.2.201', port=4370) +try: + conn = zk.connect() + print ("Restart Device...") + conn.restart() +except Exception as e: + print ("Process terminate : {}".format(e)) +finally: + if conn: + conn.disconnect() diff --git a/example/sync_time.py b/example/sync_time.py new file mode 100644 index 0000000..dc54c22 --- /dev/null +++ b/example/sync_time.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- +import os +import sys +from datetime import datetime + +CWD = os.path.dirname(os.path.realpath(__file__)) +ROOT_DIR = os.path.dirname(CWD) +sys.path.append(ROOT_DIR) + +from zk import ZK, const + + +conn = None +zk = ZK('192.168.2.201', port=4370) +try: + conn = zk.connect() + print ("Syncing time...") + conn.set_time(datetime.now()) +except Exception as e: + print ("Process terminate : {}".format(e)) +finally: + if conn: + conn.disconnect() diff --git a/example/test_voice.py b/example/test_voice.py new file mode 100644 index 0000000..983fde2 --- /dev/null +++ b/example/test_voice.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- +import os +import sys +import time + +CWD = os.path.dirname(os.path.realpath(__file__)) +ROOT_DIR = os.path.dirname(CWD) +sys.path.append(ROOT_DIR) + +from zk import ZK, const + + +conn = None +zk = ZK('192.168.2.201', port=4370) +try: + conn = zk.connect() + for i in range(0, 55): + print ("Voice number #%d" % i) + conn.test_voice(i) + time.sleep(3) +except Exception as e: + print ("Process terminate : {}".format(e)) +finally: + if conn: + conn.disconnect()