update documentation

This commit is contained in:
Fanani M. Ihsan 2016-06-24 19:09:25 +07:00
parent c6b8cf1200
commit f500083a59
2 changed files with 28 additions and 31 deletions

View File

@ -20,8 +20,6 @@ Create an ZK instnace and you will ready to call api.
``` ```
from zk import ZK, const from zk import ZK, const
sys.path.append("zk")
conn = None conn = None
zk = ZK('192.168.1.10', port=4370, timeout=5) zk = ZK('192.168.1.10', port=4370, timeout=5)
try: try:

View File

@ -7,7 +7,7 @@
Welcome to pyzk's documentation! Welcome to pyzk's documentation!
******************************** ********************************
pyzk is unofficial library for zksoftware the fingerprint attendance machine. It's easy to use and no need to understand how to communicate to device. Just create ZK instance and you will ready to use api. pyzk is an unofficial library of zksoftware the fingerprint attendance machine. It's easy to use and no need to understand how to communicate to device. Just create ZK instance and you will ready to use api.
Installation Installation
############ ############
@ -35,21 +35,18 @@ Basic Usage
.. code-block:: python .. code-block:: python
import zk from zk import ZK, const
from zk import const
conn = False conn = None
zk = zk.ZK(ip='192.168.1.201', port=4370, timeout=5) zk = ZK('192.168.1.10', port=4370, timeout=5)
try: try:
print 'Connecting to device ...'
conn = zk.connect() conn = zk.connect()
print 'Disabling device ...'
# disable (lock) the device, make sure no activity when process run conn.disable_device()
zk.disable_device() print 'Firmware Version: : {}'.format(conn.get_firmware_version())
# print '--- Get User ---'
# Do another task here users = conn.get_users()
firmware_version = zk.get_firmware_version()
print 'Firmware Version: : {}'.format(firmware_version)
users = zk.get_users()
for user in users: for user in users:
privilege = 'User' privilege = 'User'
if user.privilege == const.USER_ADMIN: if user.privilege == const.USER_ADMIN:
@ -62,13 +59,15 @@ Basic Usage
print ' Group ID : {}'.format(user.group_id) print ' Group ID : {}'.format(user.group_id)
print ' User ID : {}'.format(user.user_id) print ' User ID : {}'.format(user.user_id)
# don't forget to re-enable device print "Voice Test ..."
zk.enable_device() conn.test_voice()
print 'Enabling device ...'
conn.enable_device()
except Exception, e: except Exception, e:
print "Process terminate : {}".format(e) print "Process terminate : {}".format(e)
finally: finally:
if conn: if conn:
zk.disconnect() conn.disconnect()
API Ussage API Ussage
########## ##########
@ -77,23 +76,23 @@ API Ussage
.. code-block:: python .. code-block:: python
zk.connect() conn = zk.connect()
zk.disconnect() conn.disconnect()
**Disable/Enable Connected Device** **Disable/Enable Connected Device**
.. code-block:: python .. code-block:: python
zk.disable_device() conn.disable_device()
zk.enable_device() conn.enable_device()
**Ger Firmware Version** **Ger Firmware Version**
.. code-block:: python .. code-block:: python
zk.get_firmware_version() conn.get_firmware_version()
**User Operation** **User Operation**
@ -101,11 +100,11 @@ API Ussage
.. code-block:: python .. code-block:: python
# Create user # Create user
zk.set_user(uid=1, name='Fanani M. Ihsan', privilege=const.USER_ADMIN, password='12345678', group_id='', user_id='123') conn.set_user(uid=1, name='Fanani M. Ihsan', privilege=const.USER_ADMIN, password='12345678', group_id='', user_id='123')
# Get all users (will return list of User object) # Get all users (will return list of User object)
users = zk.get_users() users = conn.get_users()
# Delete User # Delete User
zk.delete_user(uid=1) conn.delete_user(uid=1)
**Attendance Record** **Attendance Record**
@ -113,16 +112,16 @@ API Ussage
.. code-block:: python .. code-block:: python
# Get attendances (will return list of Attendance object) # Get attendances (will return list of Attendance object)
attendances = zk.get_attendance() attendances = conn.get_attendance()
# Clear attendances record # Clear attendances record
zk.clear_attendance() conn.clear_attendance()
**Test voice** **Test voice**
.. code-block:: python .. code-block:: python
zk.test_voice() conn.test_voice()
**Device Maintenance** **Device Maintenance**
@ -130,9 +129,9 @@ API Ussage
.. code-block:: python .. code-block:: python
# shutdown connected device # shutdown connected device
zk.power_off() conn.power_off()
# restart connected device # restart connected device
zk.restart() conn.restart()
Technical Documentation Technical Documentation