From a726545d18df7989e27cc15e851f2734c5cffcbc Mon Sep 17 00:00:00 2001 From: Arturo Hernandez Date: Tue, 21 Aug 2018 09:00:46 -0400 Subject: [PATCH] test missing timeout --- README.md | 29 ++++++++++++++++++----------- zk/base.py | 2 ++ 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index b385843..2cd3acb 100644 --- a/README.md +++ b/README.md @@ -7,10 +7,22 @@ pyzk is an unofficial library of zksoftware the fingerprint attendance machine. [![Build Status](https://travis-ci.org/kurenai-ryu/pyzk.svg?branch=master)](https://travis-ci.org/kurenai-ryu/pyzk) replace original pyzk, if it was installed -`pip install -U git+https://github.com/kurenai-ryu/pyzk.git` + +```sh +pip install -U git+https://github.com/kurenai-ryu/pyzk.git +``` + +or using pipenv: + +```sh +pipenv install git+https://gith.com/kurenai-ryu/pyzk#egg=pyzk +``` or clone and execute: -`python setup.py install` + +```sh +python setup.py install +``` or in your project, append the path of this project @@ -68,21 +80,21 @@ finally: * Connect/Disconnect -``` +```python conn = zk.connect() conn.disconnect() ``` * Disable/Enable Connected Device -``` +```python conn.disable_device() conn.enable_device() ``` * Get and Set Time -``` +```python from datetime import datetime zktime = conn.get_time() @@ -95,7 +107,7 @@ conn.set_time(newtime) * Ger Firmware Version and extra information -``` +```python conn.get_firmware_version() conn.get_serialnumber() conn.get_platform() @@ -235,7 +247,6 @@ optional arguments: -F FINGER, --finger FINGER Finger for enroll (fid=0) - ``` # Compatible devices @@ -288,8 +299,6 @@ Platform : JZ4725_TFT DeviceName : K14 (not tested, but same behavior like the other one) ``` - - ### Not Working (needs more tests, more information) ``` @@ -300,8 +309,6 @@ DeviceName : iClock260 (no capture data - probably similar problem as the latest If you have another version tested and it worked, please inform me to update this list! - - # Related Project (TODO: check compatibility with this fork) * [zkcluster](https://github.com/fananimi/zkcluster/ "zkcluster project") is a django apps to manage multiple fingerprint devices. diff --git a/zk/base.py b/zk/base.py index f901c6b..1f90185 100644 --- a/zk/base.py +++ b/zk/base.py @@ -140,9 +140,11 @@ class ZK(object): """ based on self.tcp""" if self.tcp: self.__sock = socket(AF_INET, SOCK_STREAM) + self.__sock.settimeout(self.__timeout) self.__sock.connect_ex(self.__address) else: self.__sock = socket(AF_INET, SOCK_DGRAM) + self.__sock.settimeout(self.__timeout) def __create_tcp_top(self, packet): """ witch the complete packet set top header """