diff options
| author | Michael Biebl <biebl@debian.org> | 2020-10-05 22:28:16 +0200 |
|---|---|---|
| committer | Michael Biebl <biebl@debian.org> | 2020-10-05 22:28:16 +0200 |
| commit | 47a2114d6f697a31d84c8874c49e94dd04119d75 (patch) | |
| tree | e3022686ff1956d7f17f1f7cdf7022ce980b7a5c /examples/python/dbus/list-devices.py | |
| parent | 9d722f3d3492e31c0b3e4bcba603ffd65309c621 (diff) | |
| parent | aafc1dbe4712c86189bbc1d4d54ad8cb4c69be7e (diff) | |
Update upstream source from tag 'upstream/1.27.90'
Update to upstream version '1.27.90' with Debian dir 72a0791efa5966be1724a82dfcac90f6cd22bd1b
Diffstat (limited to 'examples/python/dbus/list-devices.py')
| -rwxr-xr-x | examples/python/dbus/list-devices.py | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/examples/python/dbus/list-devices.py b/examples/python/dbus/list-devices.py index 882841e6..910bc461 100755 --- a/examples/python/dbus/list-devices.py +++ b/examples/python/dbus/list-devices.py @@ -4,11 +4,17 @@ # Copyright (C) 2011 - 2012 Red Hat, Inc. # -import dbus +import dbus, socket, struct # This example lists basic information about network interfaces known to NM # For the types see include/NetworkManager.h + + +def int_to_ip(ip_int): + return socket.inet_ntoa(struct.pack("=I", ip_int)) + + devtypes = { 1: "Ethernet", 2: "Wi-Fi", @@ -56,19 +62,23 @@ manager = dbus.Interface(proxy, "org.freedesktop.NetworkManager") # Get all devices known to NM and print their properties devices = manager.GetDevices() + for d in devices: dev_proxy = bus.get_object("org.freedesktop.NetworkManager", d) prop_iface = dbus.Interface(dev_proxy, "org.freedesktop.DBus.Properties") props = prop_iface.GetAll("org.freedesktop.NetworkManager.Device") + print("============================") print("Interface: %s" % props["Interface"]) + print("Ip 4 Address: %s" % int_to_ip(props["Ip4Address"])) + print("Ip 4 Config: %s" % props["Ip4Config"]) + try: devtype = devtypes[props["DeviceType"]] except KeyError: devtype = "Unknown" print("Type: %s" % devtype) - print("Driver: %s" % props["Driver"]) try: |