seveas / python-networkmanager

Easy communication with NetworkManager
http://packages.python.org/python-networkmanager/
Other
163 stars 90 forks source link

NetworkManager.DeviceRemoved doesn't get invoked #55

Closed kzyapkov closed 1 year ago

kzyapkov commented 6 years ago

While other signals work fine (PropertiesChanged and DeviceAdded among others) I was not able to get a notification for DeviceRemoved. My sample code is a modified listener.py example:

import dbus.mainloop.glib
from gi.repository import GObject, GLib
import NetworkManager
import time

def out(msg):
    print("%s %s" % (time.strftime('%H:%M:%S'), msg))

def statechange(nm, interface, signal, state):
    out("State changed to %s" % NetworkManager.const('STATE', state))

def adddevice(nm, interface, signal, device_path):
    try:
        out("Device %s added" % device_path.IpInterface)
    except NetworkManager.ObjectVanished:
        # Sometimes this signal is sent for *removed* devices. Ignore.
        pass

def removedevice(*args, **kw):
    out("removedevice: {} {}".format(args, kw))

def main():
    dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
    NetworkManager.NetworkManager.OnStateChanged(statechange)
    NetworkManager.NetworkManager.OnDeviceAdded(adddevice)
    NetworkManager.NetworkManager.OnDeviceRemoved(removedevice)

    loop = GObject.MainLoop()
    loop.run()

if __name__ == '__main__':
    main()
kzyapkov commented 6 years ago

I believe the same applies for Wireless.AccessPointRemoved

seveas commented 1 year ago

Closing all PR's and issues prior to archiving this repository.