examples: fix nm-state.py example

This commit is contained in:
Jiří Klimeš
2012-12-07 13:49:04 +01:00
parent a455d42de2
commit 8a9759af4b

View File

@@ -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