From 1a765d616526efdcb4c9adfcc9b1d10f6ed8b938 Mon Sep 17 00:00:00 2001 From: "Fanani M. Ihsan" Date: Thu, 25 Apr 2019 20:29:10 +0700 Subject: [PATCH] update sample scripts --- example/get_device_info.py | 2 +- example/get_memory_info.py | 2 +- example/live_capture.py | 25 +++++++++++++++++++++++++ example/poweroff_device.py | 2 +- example/restart_device.py | 2 +- example/sync_time.py | 2 +- example/test_voice.py | 2 +- 7 files changed, 31 insertions(+), 6 deletions(-) create mode 100644 example/live_capture.py diff --git a/example/get_device_info.py b/example/get_device_info.py index 77c573c..a4a70f3 100644 --- a/example/get_device_info.py +++ b/example/get_device_info.py @@ -6,7 +6,7 @@ CWD = os.path.dirname(os.path.realpath(__file__)) ROOT_DIR = os.path.dirname(CWD) sys.path.append(ROOT_DIR) -from zk import ZK, const +from zk import ZK conn = None diff --git a/example/get_memory_info.py b/example/get_memory_info.py index 5b8529a..98239ee 100644 --- a/example/get_memory_info.py +++ b/example/get_memory_info.py @@ -6,7 +6,7 @@ CWD = os.path.dirname(os.path.realpath(__file__)) ROOT_DIR = os.path.dirname(CWD) sys.path.append(ROOT_DIR) -from zk import ZK, const +from zk import ZK conn = None diff --git a/example/live_capture.py b/example/live_capture.py new file mode 100644 index 0000000..f65d6e1 --- /dev/null +++ b/example/live_capture.py @@ -0,0 +1,25 @@ +# -*- 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 + + +conn = None +zk = ZK('192.168.2.201', port=4370) +try: + conn = zk.connect() + for attendance in conn.live_capture(): + if attendance is None: + pass + else: + print (attendance) +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 index 42c54a4..6506d04 100644 --- a/example/poweroff_device.py +++ b/example/poweroff_device.py @@ -6,7 +6,7 @@ CWD = os.path.dirname(os.path.realpath(__file__)) ROOT_DIR = os.path.dirname(CWD) sys.path.append(ROOT_DIR) -from zk import ZK, const +from zk import ZK conn = None diff --git a/example/restart_device.py b/example/restart_device.py index 8374fa6..8741398 100644 --- a/example/restart_device.py +++ b/example/restart_device.py @@ -6,7 +6,7 @@ CWD = os.path.dirname(os.path.realpath(__file__)) ROOT_DIR = os.path.dirname(CWD) sys.path.append(ROOT_DIR) -from zk import ZK, const +from zk import ZK conn = None diff --git a/example/sync_time.py b/example/sync_time.py index dc54c22..a8460cb 100644 --- a/example/sync_time.py +++ b/example/sync_time.py @@ -7,7 +7,7 @@ CWD = os.path.dirname(os.path.realpath(__file__)) ROOT_DIR = os.path.dirname(CWD) sys.path.append(ROOT_DIR) -from zk import ZK, const +from zk import ZK conn = None diff --git a/example/test_voice.py b/example/test_voice.py index 983fde2..b71c660 100644 --- a/example/test_voice.py +++ b/example/test_voice.py @@ -7,7 +7,7 @@ CWD = os.path.dirname(os.path.realpath(__file__)) ROOT_DIR = os.path.dirname(CWD) sys.path.append(ROOT_DIR) -from zk import ZK, const +from zk import ZK conn = None