Re: org.freedesktop.NetworkManager.Settings.PropertiesChanged deprecated



On Mittwoch, 14. Juli 2021 19:47:42 CEST Andrei Borzenkov via networkmanager-
list wrote:
[...]
I do not see any reference to object here so I have no idea what this
code does. The following certainly works

def properties_changed(interface_name, changed_properties,
invalidated_properties):
    print (interface_name, changed_properties, invalidated_properties)


bus = dbus.SystemBus()
obj = bus.get_object("org.freedesktop.NetworkManager",
"/org/freedesktop/NetworkManager")
iface = dbus.Interface(obj, "org.freedesktop.DBus.Properties")
iface.connect_to_signal("PropertiesChanged", properties_changed)


This example doesn't work here (probaly different python version?):

#!/usr/bin/python3

import dbus

def properties_changed(interface_name, changed_properties,
invalidated_properties):
    print (interface_name, changed_properties, invalidated_properties)

bus = dbus.SystemBus()
obj = bus.get_object("org.freedesktop.NetworkManager",
"/org/freedesktop/NetworkManager")
iface = dbus.Interface(obj, "org.freedesktop.DBus.Properties")
iface.connect_to_signal("PropertiesChanged", properties_changed)

gives:

  File "./b", line 13, in <module>
    iface.connect_to_signal("PropertiesChanged", properties_changed)
  File "/usr/lib/python3.8/site-packages/dbus/proxies.py", line 545, in 
connect_to_signal
    return self._obj.connect_to_signal(signal_name, handler_function,
  File "/usr/lib/python3.8/site-packages/dbus/proxies.py", line 366, in 
connect_to_signal
    self._bus.add_signal_receiver(handler_function,
  File "/usr/lib/python3.8/site-packages/dbus/bus.py", line 148, in 
add_signal_receiver
    match = super(BusConnection, self).add_signal_receiver(
  File "/usr/lib/python3.8/site-packages/dbus/connection.py", line 402, in 
add_signal_receiver
    self._require_main_loop()
RuntimeError: To make asynchronous calls, receive signals or export objects, 
D-Bus connections must be attached to a main loop by passing mainloop=... to 
the constructor or calling dbus.set_default_main_loop(...)





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]