Where can I find a Python wrapper for libprint? If such wrapper does not exist, is it possi开发者_运维知识库ble to write one? How can I get started?
As libfprint (I hope it is the project you are looking for) is using GLib, you might want to look into GObject Introspection.
I also made a lot of search for this, and I did learn a lot of C/C++ while trying to use libfprint as it is, but someday, out of nowhere, I saw a question some guy posted here and voilà:
https://github.com/luksan/pyfprint
As said in the @plaes's answer it's possible to use libfprint (or libfprint-2) from Python with GObject Introspection (GI).
You should have the correct packages installed. In Ubuntu 20.04, I installed python3-gi
:
sudo apt install python3-gi
And then you can use the library like this from the python3 shell:
import gi
gi.require_version('FPrint', '2.0')
from gi.repository import FPrint, GLib
dir(FPrint)
In the dir result you'll see the exported names available. Refer to libfprint API documentation for usage: https://fprint.freedesktop.org/libfprint-dev/
Here's a simple example to get started:
ctx = FPrint.Context()
devices = ctx.get_devices()
print([dev.get_name() for dev in devices])
Note that there is also a D-Bus API available to fprintd: https://fprint.freedesktop.org/fprintd-dev/ref-dbus.html
精彩评论