added raw finger template (dump) for test_machine

TODO: upload dumped finger
This commit is contained in:
Arturo Hernandez 2018-07-27 18:14:58 -04:00
parent 20b1768ca8
commit cd2ae44b92
3 changed files with 40 additions and 19 deletions

View File

@ -188,9 +188,11 @@ for attendance in conn.live_capture():
pass pass
else: else:
print (attendance) # Attendance object print (attendance) # Attendance object
#
#if you need to break gracefully just set #if you need to break gracefully just set
# conn.end_live_capture = True # conn.end_live_capture = True
# on interactive mode, #
# On interactive mode,
# use Ctrl+C to break gracefully # use Ctrl+C to break gracefully
# this way it restores timeout # this way it restores timeout
# and disables live capture # and disables live capture
@ -214,9 +216,11 @@ optional arguments:
Default [10] seconds (0: disable timeout) Default [10] seconds (0: disable timeout)
-P PASSWORD, --password PASSWORD -P PASSWORD, --password PASSWORD
Device code/password Device code/password
-b, --basic get Basic Information only. (no bulk read, ie: users)
-f, --force-udp Force UDP communication -f, --force-udp Force UDP communication
-v, --verbose Print debug information -v, --verbose Print debug information
-t, --templates Get templates / fingers -t, --templates Get templates / fingers (compare bulk and single read)
-tr, --templates-raw Get raw templates (dump templates)
-r, --records Get attendance records -r, --records Get attendance records
-u, --updatetime Update Date/Time -u, --updatetime Update Date/Time
-l, --live-capture Live Event Capture -l, --live-capture Live Event Capture
@ -307,7 +311,7 @@ If you have another version tested and it worked, please inform me to update thi
# Todo # Todo
* Create better documentation * Create better documentation
* Finger template downloader & uploader * ~~Finger template downloader & uploader~~
* HTTP Rest api * HTTP Rest api
* Create real time api (if possible) * ~~Create real time api (if possible)~~
* and much more ... * and much more ...

View File

@ -5,6 +5,7 @@ import traceback
import argparse import argparse
import time import time
import datetime import datetime
import codecs
from builtins import input from builtins import input
sys.path.append("zk") sys.path.append("zk")
@ -31,13 +32,15 @@ parser.add_argument('-T', '--timeout', type=int,
parser.add_argument('-P', '--password', type=int, parser.add_argument('-P', '--password', type=int,
help='Device code/password', default=0) help='Device code/password', default=0)
parser.add_argument('-b', '--basic', action="store_true", parser.add_argument('-b', '--basic', action="store_true",
help='display Basic Information (no buld read, ie: users)') help='get Basic Information only. (no bulk read, ie: users)')
parser.add_argument('-f', '--force-udp', action="store_true", parser.add_argument('-f', '--force-udp', action="store_true",
help='Force UDP communication') help='Force UDP communication')
parser.add_argument('-v', '--verbose', action="store_true", parser.add_argument('-v', '--verbose', action="store_true",
help='Print debug information') help='Print debug information')
parser.add_argument('-t', '--templates', action="store_true", parser.add_argument('-t', '--templates', action="store_true",
help='Get templates / fingers') help='Get templates / fingers (compare bulk and single read)')
parser.add_argument('-tr', '--templates-raw', action="store_true",
help='Get raw templates (dump templates)')
parser.add_argument('-r', '--records', action="store_true", parser.add_argument('-r', '--records', action="store_true",
help='Get attendance records') help='Get attendance records')
parser.add_argument('-u', '--updatetime', action="store_true", parser.add_argument('-u', '--updatetime', action="store_true",
@ -178,23 +181,34 @@ try:
conn.refresh_data() conn.refresh_data()
#print ("Voice Test ...") #print ("Voice Test ...")
#conn.test_voice(10) #conn.test_voice(10)
if args.templates: if args.templates or args.templates_raw:
print ("Read Templates...") print ("Read Templates...")
inicio = time.time() inicio = time.time()
templates = conn.get_templates() templates = conn.get_templates()
final = time.time() final = time.time()
print (' took {:.3f}[s]'.format(final - inicio)) print (' took {:.3f}[s]'.format(final - inicio))
print ('now checking individually...') if args.templates:
for tem in templates: print ('now checking individually...')
tem2 =conn.get_user_template(tem.uid,tem.fid) i = 0
if tem2 is None: for tem in templates:
print ("bulk! %s" % tem) i += 1
elif tem == tem2: # compare with alternative method tem2 =conn.get_user_template(tem.uid,tem.fid)
print ("OK! %s" % tem) if tem2 is None:
else: print ("%i: bulk! %s" % (i, tem))
print ("dif-1 %s" % tem) elif tem == tem2: # compare with alternative method
print ("dif-2 %s" % tem2) print ("%i: OK! %s" % (i, tem))
print (' took {:.3f}[s]'.format(final - inicio)) else:
print ("%i: dif-1 %s" % (i, tem))
print ("%i: dif-2 %s" % (i, tem2))
print (' took {:.3f}[s]'.format(final - inicio))
else:
print ('template dump')
i = 0
for tem in templates:
i += 1
print ("%i: %s" % (i, tem.dump()))
print (' took {:.3f}[s]'.format(final - inicio))
if args.records: if args.records:
print ("Read Records...") print ("Read Records...")
inicio = time.time() inicio = time.time()
@ -203,7 +217,7 @@ try:
print (' took {:.3f}[s]'.format(final - inicio)) print (' took {:.3f}[s]'.format(final - inicio))
i = 0 i = 0
for att in attendance: for att in attendance:
i +=1 i += 1
print ("ATT {:>6}: uid:{:>3}, user_id:{:>8} t: {}, s:{} p:{}".format(i, att.uid, att.user_id, att.timestamp, att.status, att.punch)) print ("ATT {:>6}: uid:{:>3}, user_id:{:>8} t: {}, s:{} p:{}".format(i, att.uid, att.user_id, att.timestamp, att.status, att.punch))
print (' took {:.3f}[s]'.format(final - inicio)) print (' took {:.3f}[s]'.format(final - inicio))
print ('') print ('')

View File

@ -25,3 +25,6 @@ class Finger(object):
def __repr__(self): def __repr__(self):
return "<Finger> [uid:{:>3}, fid:{}, size:{:>4} v:{} t:{}]".format(self.uid, self.fid, self.size, self.valid, self.mark) return "<Finger> [uid:{:>3}, fid:{}, size:{:>4} v:{} t:{}]".format(self.uid, self.fid, self.size, self.valid, self.mark)
def dump(self):
return "<Finger> [uid:{:>3}, fid:{}, size:{:>4} v:{} t:{}]".format(self.uid, self.fid, self.size, self.valid, codecs.encode(self.template, 'hex'))