summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorJiří Klimeš <jklimes@redhat.com>2012-12-07 13:49:04 +0100
committerJiří Klimeš <jklimes@redhat.com>2012-12-07 15:13:22 +0100
commit8a9759af4bfd4438ab89a4c24a1fc767bcd19440 (patch)
tree7834916c3529c1a1d437d9fcf0221faaa60dc386 /examples
parenta455d42de27c9e135942d189e2a37b71f0df8738 (diff)
examples: fix nm-state.py example
Diffstat (limited to 'examples')
-rw-r--r--examples/python/nm-state.py21
1 files changed, 18 insertions, 3 deletions
diff --git a/examples/python/nm-state.py b/examples/python/nm-state.py
index a79b340595..94fa630999 100644
--- a/examples/python/nm-state.py
+++ b/examples/python/nm-state.py
@@ -14,11 +14,26 @@
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
-# Copyright (C) 2010 Red Hat, Inc.
+# Copyright (C) 2010 - 2012 Red Hat, Inc.
#
import dbus
+# Device states from include/NetworkManager.h
+device_states = { 0: "Unknown",
+ 10: "Unmanaged",
+ 20: "Unavailable",
+ 30: "Disconnected",
+ 40: "Prepare",
+ 50: "Config",
+ 60: "Need Auth",
+ 70: "IP Config",
+ 80: "IP Check",
+ 90: "Secondaries",
+ 100: "Activated",
+ 110: "Deactivating",
+ 120: "Failed" }
+
bus = dbus.SystemBus()
proxy = bus.get_object("org.freedesktop.NetworkManager", "/org/freedesktop/NetworkManager")
@@ -35,10 +50,10 @@ for d in devices:
name = prop_iface.Get("org.freedesktop.NetworkManager.Device", "Interface")
# and print them out
- if state == 8: # activated
+ if state == 100 : # activated
print "Device %s is activated" % name
else:
- print "Device %s is not activated" % name
+ print "Device %s is not activated (state=%s)" % (name, device_states[state])
# Get active connection state