libfprint/tests/crfpmoc/custom.py
Felix fda0457140 cleanup todos
renamed frame to template
for unfied naming

Added myself to copyright

readded checking

Revert "readded checking"

This reverts commit 1c0b88ff3311171ddae1fd095c499f320dcca697.

clearing context after use

removed some sleeps

saving max out size and max template

tests

Revert "tests"

This reverts commit 94cf2a5d804eac5cfb2fc97d91c0d0a6770b720b.

fixed reference count error

check for successful upload

split ssm into multiple functions

improved code

removed chrfpmoc from tests since tests are broken
2026-05-01 16:12:53 +00:00

89 lines
2.3 KiB
Python
Executable file

#!/usr/bin/python3
import traceback
import sys
import gi
gi.require_version('FPrint', '2.0')
from gi.repository import FPrint, GLib
# Exit with error on any exception, included those happening in async callbacks
sys.excepthook = lambda *args: (traceback.print_exception(*args), sys.exit(1))
ctx = GLib.main_context_default()
c = FPrint.Context()
c.enumerate()
devices = c.get_devices()
d = devices[0]
del devices
assert d.get_driver() == "crfpmoc"
assert not d.has_feature(FPrint.DeviceFeature.CAPTURE)
assert d.has_feature(FPrint.DeviceFeature.IDENTIFY)
assert d.has_feature(FPrint.DeviceFeature.VERIFY)
assert not d.has_feature(FPrint.DeviceFeature.DUPLICATES_CHECK)
assert not d.has_feature(FPrint.DeviceFeature.STORAGE)
assert not d.has_feature(FPrint.DeviceFeature.STORAGE_LIST)
assert not d.has_feature(FPrint.DeviceFeature.STORAGE_DELETE)
assert d.has_feature(FPrint.DeviceFeature.STORAGE_CLEAR)
d.open_sync()
template = FPrint.Print.new(d)
def enroll_progress(*args):
print("finger status: ", d.get_finger_status())
print('enroll progress: ' + str(args))
def identify_done(dev, res):
global identified
identified = True
identify_match, identify_print = dev.identify_finish(res)
print('identification_done: ', identify_match, identify_print)
assert identify_match.equal(identify_print)
# clear, enroll, verify, identify, clear
print("clear device storage")
d.clear_storage_sync()
print("clear done")
print("enrolling")
assert d.get_finger_status() == FPrint.FingerStatusFlags.NONE
p = d.enroll_sync(template, None, enroll_progress, None)
assert d.get_finger_status() == FPrint.FingerStatusFlags.NONE
print("enroll done")
print(p)
print("verifying")
assert d.get_finger_status() == FPrint.FingerStatusFlags.NONE
verify_res, verify_print = d.verify_sync(p)
assert d.get_finger_status() == FPrint.FingerStatusFlags.NONE
print("verify done")
print(verify_res, verify_print)
assert verify_res == True
identified = False
deserialized_prints = []
deserialized_prints.append(FPrint.Print.deserialize(p.serialize()))
assert deserialized_prints[-1].equal(p)
del p
print('async identifying')
d.identify(deserialized_prints, callback=identify_done)
del deserialized_prints
while not identified:
ctx.iteration(True)
print("clear device storage")
d.clear_storage_sync()
print("clear done")
d.close_sync()
del d
del c