update README.md
This commit is contained in:
parent
eb0e87da0a
commit
6d0a69ddee
14
README.md
14
README.md
@ -21,21 +21,19 @@ Create ZK object and you will ready to call api.
|
|||||||
import zk
|
import zk
|
||||||
from zk import const
|
from zk import const
|
||||||
|
|
||||||
|
conn = False
|
||||||
zk = zk.ZK(ip='192.168.1.201', port=4370, timeout=5)
|
zk = zk.ZK(ip='192.168.1.201', port=4370, timeout=5)
|
||||||
try:
|
try:
|
||||||
response = zk.connect()
|
conn = zk.connect()
|
||||||
if response.get('status') is False:
|
|
||||||
raise Exception(response.get('message'))
|
|
||||||
|
|
||||||
# disable (lock) the device, make sure no activity when process run
|
# disable (lock) the device, make sure no activity when process run
|
||||||
zk.disable_device()
|
zk.disable_device()
|
||||||
|
|
||||||
# Do another task here
|
# Do another task here
|
||||||
firmware = zk.get_firmware_version()
|
firmware_version = zk.get_firmware_version()
|
||||||
print 'Firmware Version: : {}'.format(firmware.get('data'))
|
print 'Firmware Version: : {}'.format(firmware_version)
|
||||||
users = zk.get_users()
|
users = zk.get_users()
|
||||||
if users.get('status'):
|
for user in users:
|
||||||
for user in users.get('data'):
|
|
||||||
privilege = 'User'
|
privilege = 'User'
|
||||||
if user.privilege == const.USER_ADMIN:
|
if user.privilege == const.USER_ADMIN:
|
||||||
privilege = 'Admin'
|
privilege = 'Admin'
|
||||||
@ -52,7 +50,7 @@ try:
|
|||||||
except Exception, e:
|
except Exception, e:
|
||||||
print "Process terminate : {}".format(e)
|
print "Process terminate : {}".format(e)
|
||||||
finally:
|
finally:
|
||||||
if zk.is_connect:
|
if conn:
|
||||||
zk.disconnect()
|
zk.disconnect()
|
||||||
|
|
||||||
```
|
```
|
||||||
|
Loading…
Reference in New Issue
Block a user