Attempt to start from udev.
This commit is contained in:
parent
04fa59ce1d
commit
cefc2f6ff5
17 changed files with 114 additions and 20 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -1,4 +1,5 @@
|
||||||
debian/tmp/
|
debian/tmp/
|
||||||
|
debian/debhelper-build-stamp
|
||||||
debian/python3-validity/
|
debian/python3-validity/
|
||||||
debian/python3-validity.substvars
|
debian/python3-validity.substvars
|
||||||
debian/python3-validity.prerm.debhelper
|
debian/python3-validity.prerm.debhelper
|
||||||
|
|
|
||||||
|
|
@ -1,4 +0,0 @@
|
||||||
# TODO me
|
|
||||||
|
|
||||||
ACTION=="add", SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device", ATTRS{idVendor}=="138a", ATTRS{idProduct}=="0097", TAG+="systemd", ENV{SYSTEMD_WANTS}+="python-validity@usb-$env{BUSNUM}-$env{DEVNUM}.service"
|
|
||||||
|
|
||||||
|
|
@ -5,6 +5,7 @@ import re
|
||||||
import dbus
|
import dbus
|
||||||
import dbus.mainloop.glib
|
import dbus.mainloop.glib
|
||||||
import dbus.service
|
import dbus.service
|
||||||
|
from binascii import hexlify, unhexlify
|
||||||
dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
|
dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
|
||||||
from gi.repository import GObject, GLib
|
from gi.repository import GObject, GLib
|
||||||
import logging
|
import logging
|
||||||
|
|
@ -147,6 +148,12 @@ class Device(dbus.service.Object):
|
||||||
def EnrollStatus(self, result, done):
|
def EnrollStatus(self, result, done):
|
||||||
logging.debug('EnrollStatus')
|
logging.debug('EnrollStatus')
|
||||||
|
|
||||||
|
@dbus.service.method(dbus_interface=INTERFACE_NAME,
|
||||||
|
in_signature='s',
|
||||||
|
out_signature='s')
|
||||||
|
def RunCmd(self, cmd):
|
||||||
|
logging.debug('RunCmd')
|
||||||
|
return hexlify(tls.app(unhexlify(cmd))).decode()
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
parser = argparse.ArgumentParser('Open fprintd DBus service')
|
parser = argparse.ArgumentParser('Open fprintd DBus service')
|
||||||
|
|
|
||||||
|
|
@ -1,12 +0,0 @@
|
||||||
# TODO me
|
|
||||||
|
|
||||||
[Unit]
|
|
||||||
Description=python-validity driver dbus service for %I
|
|
||||||
|
|
||||||
[Service]
|
|
||||||
Type=simple
|
|
||||||
ExecStart=/usr/lib/python-validity/dbus-service %i
|
|
||||||
Restart=no
|
|
||||||
|
|
||||||
#[Install]
|
|
||||||
#WantedBy=multi-user.target
|
|
||||||
2
debian/compat
vendored
2
debian/compat
vendored
|
|
@ -1 +1 @@
|
||||||
9
|
11
|
||||||
|
|
|
||||||
4
debian/control
vendored
4
debian/control
vendored
|
|
@ -2,12 +2,12 @@ Source: python-validity
|
||||||
Section: misc
|
Section: misc
|
||||||
Priority: optional
|
Priority: optional
|
||||||
Maintainer: uunicorn <viktor.dragomiretskyy@gmail.com>
|
Maintainer: uunicorn <viktor.dragomiretskyy@gmail.com>
|
||||||
Build-Depends: debhelper (>= 7.0.50~),
|
Build-Depends: debhelper (>= 11~),
|
||||||
dh-python,
|
dh-python,
|
||||||
python3-all,
|
python3-all,
|
||||||
python3-setuptools
|
python3-setuptools
|
||||||
X-Python3-Version: >= 3.6
|
X-Python3-Version: >= 3.6
|
||||||
Standards-Version: 3.9.2
|
Standards-Version: 4.1.4
|
||||||
|
|
||||||
Package: python3-validity
|
Package: python3-validity
|
||||||
Architecture: all
|
Architecture: all
|
||||||
|
|
|
||||||
11
debian/python3-validity.postinst
vendored
Normal file
11
debian/python3-validity.postinst
vendored
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
#!/bin/sh
|
||||||
|
set -e
|
||||||
|
|
||||||
|
#DEBHELPER#
|
||||||
|
|
||||||
|
if [ "$1" = "configure" ]; then
|
||||||
|
systemctl daemon-reload || true
|
||||||
|
udevadm control --reload-rules || true
|
||||||
|
udevadm trigger || true
|
||||||
|
fi
|
||||||
|
|
||||||
12
debian/python3-validity.prerm
vendored
Normal file
12
debian/python3-validity.prerm
vendored
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
#! /bin/sh
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# Stop the socket on remove so syslog-ng is not restarted via socket activation
|
||||||
|
if [ -x "/usr/bin/deb-systemd-invoke" ] && [ "$1" = remove ]; then
|
||||||
|
deb-systemd-invoke stop 'python3-validity@*' || true
|
||||||
|
fi
|
||||||
|
|
||||||
|
#DEBHELPER#
|
||||||
|
|
||||||
|
exit 0
|
||||||
19
debian/python3-validity.udev
vendored
Normal file
19
debian/python3-validity.udev
vendored
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
SUBSYSTEM!="usb", GOTO="python_validity_end"
|
||||||
|
ENV{DEVTYPE}!="usb_device", GOTO="python_validity_end"
|
||||||
|
|
||||||
|
ATTRS{idVendor}=="138a", ATTRS{idProduct}=="0090", GOTO="python_validity_match"
|
||||||
|
ATTRS{idVendor}=="138a", ATTRS{idProduct}=="0097", GOTO="python_validity_match"
|
||||||
|
ATTRS{idVendor}=="06cb", ATTRS{idProduct}=="009a", GOTO="python_validity_match"
|
||||||
|
|
||||||
|
GOTO="python_validity_end"
|
||||||
|
|
||||||
|
LABEL="python_validity_match"
|
||||||
|
|
||||||
|
#TAG+="validity"
|
||||||
|
|
||||||
|
ACTION=="add|change", RUN+="/bin/systemctl --no-block start python3-validity@usb-$env{BUSNUM}-$env{DEVNUM}.service"
|
||||||
|
ACTION=="remove", RUN+="/bin/systemctl --no-block stop python3-validity@usb-$env{BUSNUM}-$env{DEVNUM}.service"
|
||||||
|
# TODO: Figure out why the following is not working properly instead:
|
||||||
|
#TAG+="systemd", ENV{SYSTEMD_WANTS}+="python3-validity@usb-$env{BUSNUM}-$env{DEVNUM}.service"
|
||||||
|
|
||||||
|
LABEL="python_validity_end"
|
||||||
9
debian/python3-validity@.service
vendored
Normal file
9
debian/python3-validity@.service
vendored
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
[Unit]
|
||||||
|
Description=python-validity driver dbus service for %I
|
||||||
|
#StopWhenUnneeded=true
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=simple
|
||||||
|
ExecStart=/usr/lib/python-validity/dbus-service --devpath %i
|
||||||
|
Restart=no
|
||||||
|
|
||||||
4
debian/rules
vendored
4
debian/rules
vendored
|
|
@ -5,6 +5,10 @@
|
||||||
%:
|
%:
|
||||||
dh $@ --with python3 --buildsystem=pybuild
|
dh $@ --with python3 --buildsystem=pybuild
|
||||||
|
|
||||||
|
override_dh_installsystemd:
|
||||||
|
dh_installsystemd
|
||||||
|
|
||||||
|
|
||||||
override_dh_auto_install:
|
override_dh_auto_install:
|
||||||
python3 ./setup.py install --root=$(CURDIR)/debian/tmp --prefix=/usr --install-layout=deb
|
python3 ./setup.py install --root=$(CURDIR)/debian/tmp --prefix=/usr --install-layout=deb
|
||||||
|
|
||||||
|
|
|
||||||
16
scripts/dbus-cmd.py
Executable file
16
scripts/dbus-cmd.py
Executable file
|
|
@ -0,0 +1,16 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
import argparse
|
||||||
|
import re
|
||||||
|
import dbus
|
||||||
|
import dbus.mainloop.glib
|
||||||
|
dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
|
||||||
|
from gi.repository import GObject, GLib
|
||||||
|
import sys
|
||||||
|
|
||||||
|
bus = dbus.SystemBus()
|
||||||
|
o = bus.get_object('net.reactivated.Fprint', '/net/reactivated/Fprint/Manager', introspect=False)
|
||||||
|
o = o.GetDefaultDevice()
|
||||||
|
o = bus.get_object('net.reactivated.Fprint', o, introspect=False)
|
||||||
|
o = dbus.Interface(o, 'net.reactivated.Fprint.Device')
|
||||||
|
print(o.RunCmd(sys.argv[1]))
|
||||||
25
scripts/lsdbus.py
Executable file
25
scripts/lsdbus.py
Executable file
|
|
@ -0,0 +1,25 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
import argparse
|
||||||
|
import re
|
||||||
|
import dbus
|
||||||
|
import dbus.mainloop.glib
|
||||||
|
dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
|
||||||
|
from gi.repository import GObject, GLib
|
||||||
|
|
||||||
|
import pwd
|
||||||
|
|
||||||
|
bus = dbus.SystemBus()
|
||||||
|
o = bus.get_object('org.freedesktop.DBus', '/org/freedesktop/DBus')
|
||||||
|
o = dbus.Interface(o, 'org.freedesktop.DBus')
|
||||||
|
ls = o.ListNames()
|
||||||
|
for n in ls:
|
||||||
|
if n[0] != ':':
|
||||||
|
continue
|
||||||
|
|
||||||
|
pid = o.GetConnectionUnixProcessID(n)
|
||||||
|
|
||||||
|
with open('/proc/%d/cmdline' % pid) as f:
|
||||||
|
s=f.read()
|
||||||
|
s=s.split('\0')
|
||||||
|
print('%-10s %-5d %s' % (n, pid, ' '.join(s)))
|
||||||
8
setup.py
8
setup.py
|
|
@ -15,8 +15,14 @@ setup(name='python-validity',
|
||||||
'pyusb >= 1.0.2'
|
'pyusb >= 1.0.2'
|
||||||
],
|
],
|
||||||
data_files=[
|
data_files=[
|
||||||
('share/python-validity/playground/', ['factory-reset.py', 'pair.py', 'prototype.py']),
|
|
||||||
('share/dbus-1/system.d/', ['dbus_service/io.github.uunicorn.Fprint.conf']),
|
('share/dbus-1/system.d/', ['dbus_service/io.github.uunicorn.Fprint.conf']),
|
||||||
('lib/python-validity/', ['dbus_service/dbus-service']),
|
('lib/python-validity/', ['dbus_service/dbus-service']),
|
||||||
|
('share/python-validity/playground/', [
|
||||||
|
'scripts/dbus-cmd.py',
|
||||||
|
'scripts/lsdbus.py',
|
||||||
|
'scripts/factory-reset.py',
|
||||||
|
'scripts/pair.py',
|
||||||
|
'scripts/prototype.py'
|
||||||
|
]),
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue