Last active
December 3, 2019 00:17
-
-
Save davesteele/fbb16bd9d297ca71d18f44e4dcf676ad to your computer and use it in GitHub Desktop.
Possible dbussy ravel listen_signal bug?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE busconfig PUBLIC | |
"-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN" | |
"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd"> | |
<!-- store in /etc/dbus-1/system.d --> | |
<busconfig> | |
<policy user="root"> | |
<allow own="com.foo"/> | |
</policy> | |
<policy context="default"> | |
<allow send_destination="com.foo"/> | |
<allow receive_sender="com.foo"/> | |
</policy> | |
</busconfig> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import asyncio | |
import ravel | |
from dbussy import DBUS | |
""" | |
This script runs using the DBus bus name "com.foo". | |
It serves the path /com/Foo, while listening to /org/freedesktop/NetworkManager. | |
The NetworkManager paths are showing up in the com.foo bus space, with the | |
three standard DBus interfaces. Is this a bug? | |
See https://github.com/ldo/dbussy/issues/27 | |
""" | |
bus = ravel.system_bus() | |
loop = asyncio.get_event_loop() | |
bus.attach_asyncio(loop) | |
bus.request_name(bus_name="com.foo", flags=DBUS.NAME_FLAG_DO_NOT_QUEUE) | |
@ravel.interface(ravel.INTERFACE.SERVER, name="com.foo") | |
class FooInterface: | |
@ravel.method( | |
name="Foo", | |
in_signature="", | |
out_signature="", | |
) | |
def foo(self): | |
pass | |
foo = FooInterface() | |
bus.register("/com/Foo", fallback=False, interface=foo) | |
@ravel.signal(name="DeviceRemoved", in_signature="o") | |
def device_rm(nm_path): | |
print("{} removed".format(nm_path)) | |
ravel.system_bus().listen_signal( | |
path="/org/freedesktop/NetworkManager", | |
fallback=False, | |
interface="org.freedesktop.NetworkManager", | |
name="DeviceRemoved", | |
func=device_rm, | |
) | |
loop.run_forever() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment