我在哪里可以找到libprint的Python包装器?如果这样的包装器不存在,是否可以写一个?我该如何开始?
答案 0 :(得分:4)
由于libfprint(我希望这是您正在寻找的项目)使用的是GLib,您可能需要查看GObject Introspection。
答案 1 :(得分:4)
我也做了很多搜索,并且在尝试使用 libfprint 时确实学到了很多C / C ++,但总有一天,我看到{{{ 3}}有些人发布在这里并且瞧瞧:
答案 2 :(得分:0)
如@plaes 的回答所述,可以将 Python 中的 libfprint(或 libfprint-2)与 GObject Introspection (GI) 结合使用。
您应该安装了正确的软件包。在 Ubuntu 20.04 中,我安装了 python3-gi
:
sudo apt install python3-gi
然后你可以像这样从 python3 shell 使用这个库:
import gi
gi.require_version('FPrint', '2.0')
from gi.repository import FPrint, GLib
dir(FPrint)
在目录结果中,您将看到可用的导出名称。有关用法,请参阅 libfprint API 文档:https://fprint.freedesktop.org/libfprint-dev/
这是一个简单的入门示例:
ctx = FPrint.Context()
devices = ctx.get_devices()
print([dev.get_name() for dev in devices])
请注意,还有一个可用于 fprintd 的 D-Bus API:https://fprint.freedesktop.org/fprintd-dev/ref-dbus.html