From 9fdb4f96c549cc44056fd5b15ba4ec6e7ac633be Mon Sep 17 00:00:00 2001 From: fedotovaleksandr Date: Mon, 4 Feb 2019 16:49:39 +0700 Subject: [PATCH 1/4] Add compatibility with python 3 - relative imports, fix xrange, fix tests --- .travis.yml | 2 ++ test.py | 7 ++++++- zk/base.py | 12 ++++++------ 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index b6614b7..ebcb154 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,7 @@ language: python python: - "2.7" + - "3.6" + - "3.7" # command to run tests script: python test.py diff --git a/test.py b/test.py index 4b7bffb..05b35d4 100755 --- a/test.py +++ b/test.py @@ -5,7 +5,12 @@ import sys import os import unittest import codecs -from mock import patch, Mock, MagicMock + +if sys.version_info[0] < 3: + from mock import patch, Mock, MagicMock +else: + from unittest.mock import patch, Mock, MagicMock + mock_socket = MagicMock(name='zk.socket') sys.modules['zk.socket'] = mock_socket from zk import ZK, const diff --git a/zk/base.py b/zk/base.py index 738f005..969b3c3 100644 --- a/zk/base.py +++ b/zk/base.py @@ -5,11 +5,11 @@ from socket import AF_INET, SOCK_DGRAM, SOCK_STREAM, socket, timeout from struct import pack, unpack import codecs -from zk import const -from zk.attendance import Attendance -from zk.exception import ZKErrorConnection, ZKErrorResponse, ZKNetworkError -from zk.user import User -from zk.finger import Finger +from . import const +from .attendance import Attendance +from .exception import ZKErrorConnection, ZKErrorResponse, ZKNetworkError +from .user import User +from .finger import Finger def safe_cast(val, to_type, default=None): @@ -302,7 +302,7 @@ class ZK(object): def __reverse_hex(self, hex): data = '' - for i in reversed(xrange(len(hex) / 2)): + for i in reversed(range(len(hex) / 2)): data += hex[i * 2:(i * 2) + 2] return data From 8dac6dd472e37a9b58d92e7a3871e56408045293 Mon Sep 17 00:00:00 2001 From: fedotovaleksandr Date: Mon, 4 Feb 2019 17:03:33 +0700 Subject: [PATCH 2/4] remove 3.7 from travis - it does not support --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index ebcb154..0e97c77 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,6 +2,5 @@ language: python python: - "2.7" - "3.6" - - "3.7" # command to run tests script: python test.py From 03ed6578651096e54fc079080ae90cd506ef1419 Mon Sep 17 00:00:00 2001 From: ykptke Date: Wed, 6 Mar 2019 09:57:03 +0300 Subject: [PATCH 3/4] changed card_str pack format fixes #32 --- zk/base.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/zk/base.py b/zk/base.py index 969b3c3..f105070 100644 --- a/zk/base.py +++ b/zk/base.py @@ -889,7 +889,7 @@ class ZK(object): raise ZKErrorResponse("Can't pack user") else: name_pad = name.encode(self.encoding, errors='ignore').ljust(24, b'\x00')[:24] - card_str = pack('i', int(card))[:4] + card_str = pack(' Date: Fri, 8 Mar 2019 20:22:20 +0530 Subject: [PATCH 4/4] Update README.md Added One more tested device with firmware and platform --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 23dce79..6c6bb31 100644 --- a/README.md +++ b/README.md @@ -413,6 +413,10 @@ DeviceName : K20 (latest checked correctly!) Firmware Version : Ver 6.60 Aug 23 2014 Platform : ZEM600_TFT DeviceName : VF680 (face device only, but we read the user and attendance list!) + +Firmware Version : Ver 6.70 Feb 16 2017 +Platform : ZLM30_TFT +DeviceName : RSP10k1 (latest checked correctly!) ```