summary refs log tree commit diff
path: root/examples
diff options
context:
space:
mode:
authorMichael Biebl <biebl@debian.org>2011-03-18 20:17:47 +0100
committerMichael Biebl <biebl@debian.org>2011-03-18 20:17:47 +0100
commite22c6e05e9ebc6cce941762020c5710b8014677b (patch)
tree7e9fd7f8ae24a94b03f683e0cef9a346968e1e8b /examples
parenta6b89d35fabd9f5934b84d7cde22e9268f92c3d3 (diff)
Imported Upstream version 0.8.3.998 upstream/0.8.3.998
Diffstat (limited to 'examples')
-rw-r--r--examples/Makefile.in5
-rw-r--r--examples/python/Makefile.am1
-rw-r--r--examples/python/Makefile.in14
-rwxr-xr-xexamples/python/add-system-wifi-connection.py64
-rwxr-xr-xexamples/python/disconnect-device.py62
-rw-r--r--examples/python/list-connections.py112
-rw-r--r--examples/python/nm-state.py6
-rw-r--r--examples/python/show-bssids.py78
-rw-r--r--examples/python/vpn.py152
9 files changed, 83 insertions, 411 deletions
diff --git a/examples/Makefile.in b/examples/Makefile.in
index 494a268d..ce7a12e5 100644
--- a/examples/Makefile.in
+++ b/examples/Makefile.in
@@ -189,6 +189,10 @@ MSGFMT_OPTS = @MSGFMT_OPTS@
 MSGMERGE = @MSGMERGE@
 NM = @NM@
 NMEDIT = @NMEDIT@
+NM_MAJOR_VERSION = @NM_MAJOR_VERSION@
+NM_MICRO_VERSION = @NM_MICRO_VERSION@
+NM_MINOR_VERSION = @NM_MINOR_VERSION@
+NM_VERSION = @NM_VERSION@
 NSS_CFLAGS = @NSS_CFLAGS@
 NSS_LIBS = @NSS_LIBS@
 OBJDUMP = @OBJDUMP@
@@ -203,6 +207,7 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_URL = @PACKAGE_URL@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PKGCONFIG_PATH = @PKGCONFIG_PATH@
 PKG_CONFIG = @PKG_CONFIG@
 PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
 PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
diff --git a/examples/python/Makefile.am b/examples/python/Makefile.am
index dec8b571..5650ed83 100644
--- a/examples/python/Makefile.am
+++ b/examples/python/Makefile.am
@@ -1,6 +1,7 @@
 EXTRA_DIST = \
 	nm-state.py \
 	add-system-connection.py \
+	add-system-wifi-connection.py
 	vpn.py \
 	list-connections.py \
 	show-bssids.py \
diff --git a/examples/python/Makefile.in b/examples/python/Makefile.in
index 49b50c0c..e6fdf88f 100644
--- a/examples/python/Makefile.in
+++ b/examples/python/Makefile.in
@@ -149,6 +149,10 @@ MSGFMT_OPTS = @MSGFMT_OPTS@
 MSGMERGE = @MSGMERGE@
 NM = @NM@
 NMEDIT = @NMEDIT@
+NM_MAJOR_VERSION = @NM_MAJOR_VERSION@
+NM_MICRO_VERSION = @NM_MICRO_VERSION@
+NM_MINOR_VERSION = @NM_MINOR_VERSION@
+NM_VERSION = @NM_VERSION@
 NSS_CFLAGS = @NSS_CFLAGS@
 NSS_LIBS = @NSS_LIBS@
 OBJDUMP = @OBJDUMP@
@@ -163,6 +167,7 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_URL = @PACKAGE_URL@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PKGCONFIG_PATH = @PKGCONFIG_PATH@
 PKG_CONFIG = @PKG_CONFIG@
 PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
 PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
@@ -241,10 +246,7 @@ top_srcdir = @top_srcdir@
 EXTRA_DIST = \
 	nm-state.py \
 	add-system-connection.py \
-	vpn.py \
-	list-connections.py \
-	show-bssids.py \
-	disconnect-device.py
+	add-system-wifi-connection.py
 
 all: all-am
 
@@ -430,6 +432,10 @@ uninstall-am:
 	maintainer-clean-generic mostlyclean mostlyclean-generic \
 	mostlyclean-libtool pdf pdf-am ps ps-am uninstall uninstall-am
 
+	vpn.py \
+	list-connections.py \
+	show-bssids.py \
+	disconnect-device.py
 
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
diff --git a/examples/python/add-system-wifi-connection.py b/examples/python/add-system-wifi-connection.py
new file mode 100755
index 00000000..f12723d1
--- /dev/null
+++ b/examples/python/add-system-wifi-connection.py
@@ -0,0 +1,64 @@
+#!/bin/env python
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# 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.
+#
+
+import dbus
+
+def path_to_value(path):
+    return dbus.ByteArray("file://" + path + "\0")
+
+s_con = dbus.Dictionary({
+    'type': '802-11-wireless',
+    'uuid': '7371bb78-c1f7-42a3-a9db-5b9566e8ca07',
+    'id': 'My Wifi'})
+
+s_wifi = dbus.Dictionary({
+    'ssid': dbus.ByteArray("homewifi"),
+    'security': '802-11-wireless-security'})
+
+s_wsec = dbus.Dictionary({'key-mgmt': 'wpa-eap'})
+
+s_8021x = dbus.Dictionary({
+    'eap': ['tls'],
+    'identity': 'Bill Smith',
+    'client-cert': path_to_value("/some/place/client.pem"),
+    'ca-cert': path_to_value("/some/place/ca-cert.pem"),
+    'private-key': path_to_value("/some/place/privkey.pem"),
+    'private-key-password': "12345testing"})
+
+s_ip4 = dbus.Dictionary({'method': 'auto'})
+s_ip6 = dbus.Dictionary({'method': 'ignore'})
+
+con = dbus.Dictionary({
+    'connection': s_con,
+    '802-11-wireless': s_wifi,
+    '802-11-wireless-security': s_wsec,
+    '802-1x': s_8021x,
+    'ipv4': s_ip4,
+    'ipv6': s_ip6
+     })
+
+
+bus = dbus.SystemBus()
+
+print con
+proxy = bus.get_object("org.freedesktop.NetworkManagerSystemSettings", "/org/freedesktop/NetworkManagerSettings")
+settings = dbus.Interface(proxy, "org.freedesktop.NetworkManagerSettings")
+
+settings.AddConnection(con)
+
diff --git a/examples/python/disconnect-device.py b/examples/python/disconnect-device.py
deleted file mode 100755
index f8854951..00000000
--- a/examples/python/disconnect-device.py
+++ /dev/null
@@ -1,62 +0,0 @@
-#!/bin/env python
-# -*- Mode: python; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License along
-# 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.
-#
-
-import dbus, sys
-
-# This example takes a device interface name as a parameter and tells
-# NetworkManager to disconnect that device, closing down any network
-# connection it may have
-
-if len(sys.argv) != 2:
-    raise Exception("Usage: %s <interface>" % sys.argv[0])
-
-bus = dbus.SystemBus()
-
-# Get a proxy for the base NetworkManager object
-proxy = bus.get_object("org.freedesktop.NetworkManager", "/org/freedesktop/NetworkManager")
-manager = dbus.Interface(proxy, "org.freedesktop.NetworkManager")
-
-dpath = None
-
-# Find the device the user wants to disconnect
-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")
-    iface = prop_iface.Get("org.freedesktop.NetworkManager.Device", "Interface")
-    if iface == sys.argv[1]:
-        dpath = d
-        break
-
-if not dpath or not len(dpath):
-    raise Exception("NetworkManager knows nothing about %s" % sys.argv[1])
-
-dev_proxy = bus.get_object("org.freedesktop.NetworkManager", dpath)
-dev_iface = dbus.Interface(dev_proxy, "org.freedesktop.NetworkManager.Device")
-prop_iface = dbus.Interface(dev_proxy, "org.freedesktop.DBus.Properties")
-
-# Make sure the device is connected before we try to disconnect it
-state = prop_iface.Get("org.freedesktop.NetworkManager.Device", "State")
-if state <= 3:
-    raise Exception("Device %s isn't connected" % sys.argv[1])
-
-# Tell NM to disconnect it
-dev_iface.Disconnect()
-
diff --git a/examples/python/list-connections.py b/examples/python/list-connections.py
deleted file mode 100644
index ad8d9047..00000000
--- a/examples/python/list-connections.py
+++ /dev/null
@@ -1,112 +0,0 @@
-#!/bin/env python
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License along
-# 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.
-#
-
-import dbus
-
-# This example asks both the system settings service and the user settings
-# service for all configured connections.  It also asks for secrets, demonstrating
-# the mechanisms each settings service uses to prevent unauthorized access to
-# a user's network passwords
-
-bus = dbus.SystemBus()
-
-def merge_secrets(proxy, config, setting_name):
-    try:
-        # returns a dict of dicts mapping name::setting, where setting is a dict
-        # mapping key::value.  Each member of the 'setting' dict is a secret
-        secrets = proxy.GetSecrets(setting_name, [], False)
-
-        # Copy the secrets into our connection config
-        for setting in secrets:
-            for key in secrets[setting]:
-                config[setting_name][key] = setting[key]
-    except Exception, e:
-        pass
-
-def dict_to_string(d, indent):
-    # Try to trivially translate a dictionary's elements into nice string
-    # formatting.
-    dstr = ""
-    for key in d:
-        val = d[key]
-        str_val = ""
-        add_string = True
-        if type(val) == type(dbus.Array([])):
-            for elt in val:
-                if type(elt) == type(dbus.Byte(1)):
-                    str_val += "%s " % int(elt)
-                elif type(elt) == type(dbus.String("")):
-                    str_val += "%s" % elt
-        elif type(val) == type(dbus.Dictionary({})):
-            dstr += dict_to_string(val, indent + "    ")
-            add_string = False
-        else:
-            str_val = val
-        if add_string:
-            dstr += "%s%s: %s\n" % (indent, key, str_val)
-    return dstr
-
-def connection_to_string(config):
-    # dump a connection configuration to a the console
-    for setting_name in config:
-        print "        Setting: %s" % setting_name
-        print dict_to_string(config[setting_name], "            ")
-    print ""
-
-
-def print_one_services_connections(service_name, desc):
-    # Ask the settings service for the list of connections it provides
-    proxy = bus.get_object(service_name, "/org/freedesktop/NetworkManagerSettings")
-    settings = dbus.Interface(proxy, "org.freedesktop.NetworkManagerSettings")
-    connection_paths = settings.ListConnections()
-
-    print "%s connections --------------------------------------------\n" % desc
-
-    # List each connection's name, UUID, and type
-    for path in connection_paths:
-        con_proxy = bus.get_object(service_name, path)
-        connection = dbus.Interface(con_proxy, "org.freedesktop.NetworkManagerSettings.Connection")
-        config = connection.GetSettings()
-
-        # Now get secrets too; we grab the secrets for each type of connection
-        # (since there isn't a "get all secrets" call because most of the time
-        # you only need 'wifi' secrets or '802.1x' secrets, not everything) and
-        # merge that into the configuration data
-        connection_secrets = dbus.Interface(con_proxy, "org.freedesktop.NetworkManagerSettings.Connection.Secrets")
-        merge_secrets(connection_secrets, config, '802-11-wireless')
-        merge_secrets(connection_secrets, config, '802-11-wireless-security')
-        merge_secrets(connection_secrets, config, '802-1x')
-        merge_secrets(connection_secrets, config, 'gsm')
-        merge_secrets(connection_secrets, config, 'cdma')
-        merge_secrets(connection_secrets, config, 'ppp')
-
-        # Get the details of the 'connection' setting
-	s_con = config['connection']
-	print "name: %s" % s_con['id']
-	print "    uuid: %s" % s_con['uuid']
-	print "    type: %s" % s_con['type']
-	print "    ----------------------------"
-        connection_to_string(config)
-
-    print ""
-
-# Print out connection information for all connections
-print_one_services_connections("org.freedesktop.NetworkManagerSystemSettings", "System")
-print_one_services_connections("org.freedesktop.NetworkManagerUserSettings", "User")
-
diff --git a/examples/python/nm-state.py b/examples/python/nm-state.py
index fddd2da6..2bbdd2db 100644
--- a/examples/python/nm-state.py
+++ b/examples/python/nm-state.py
@@ -47,13 +47,13 @@ active = manager_prop_iface.Get("org.freedesktop.NetworkManager", "ActiveConnect
 for a in active:
     ac_proxy = bus.get_object("org.freedesktop.NetworkManager", a)
     prop_iface = dbus.Interface(ac_proxy, "org.freedesktop.DBus.Properties")
-    state = prop_iface.Get("org.freedesktop.NetworkManager.ActiveConnection", "State")
+    state = prop_iface.Get("org.freedesktop.NetworkManager.Connection.Active", "State")
 
     # Connections in NM are a collection of settings that describe everything
     # needed to connect to a specific network.  Lets get those details so we
     # can find the user-readable name of the connection.
-    con_path = prop_iface.Get("org.freedesktop.NetworkManager.ActiveConnection", "Connection")
-    con_service = prop_iface.Get("org.freedesktop.NetworkManager.ActiveConnection", "ServiceName")
+    con_path = prop_iface.Get("org.freedesktop.NetworkManager.Connection.Active", "Connection")
+    con_service = prop_iface.Get("org.freedesktop.NetworkManager.Connection.Active", "ServiceName")
 
     # ask the provider of the connection for its details
     service_proxy = bus.get_object(con_service, con_path)
diff --git a/examples/python/show-bssids.py b/examples/python/show-bssids.py
deleted file mode 100644
index 5d8778c7..00000000
--- a/examples/python/show-bssids.py
+++ /dev/null
@@ -1,78 +0,0 @@
-#!/bin/env python
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License along
-# 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.
-#
-
-
-# This example prints out all the AP BSSIDs that all WiFi devices on the
-# machine can see.  Useful for location-based services like Skyhook that
-# can geolocate you based on the APs you can see.
-
-import dbus
-
-bus = dbus.SystemBus()
-
-# Get a proxy for the base NetworkManager object
-proxy = bus.get_object("org.freedesktop.NetworkManager", "/org/freedesktop/NetworkManager")
-manager = dbus.Interface(proxy, "org.freedesktop.NetworkManager")
-
-all_aps = []
-
-print "Associated APs:"
-
-# Get all network devices
-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")
-
-    # Make sure the device is enabled before we try to use it
-    state = prop_iface.Get("org.freedesktop.NetworkManager.Device", "State")
-    if state <= 2:
-        continue
-
-    # Get device's type; we only want wifi devices
-    iface = prop_iface.Get("org.freedesktop.NetworkManager.Device", "Interface")
-    dtype = prop_iface.Get("org.freedesktop.NetworkManager.Device", "DeviceType")
-    if dtype == 2:   # WiFi
-        # Get a proxy for the wifi interface
-        wifi_iface = dbus.Interface(dev_proxy, "org.freedesktop.NetworkManager.Device.Wireless")
-        wifi_prop_iface = dbus.Interface(dev_proxy, "org.freedesktop.DBus.Properties")
-
-        # Get the associated AP's object path
-        connected_path = wifi_prop_iface.Get("org.freedesktop.NetworkManager.Device.Wireless", "ActiveAccessPoint")
-
-        # Get all APs the card can see
-        aps = wifi_iface.GetAccessPoints()
-        for path in aps:
-            ap_proxy = bus.get_object("org.freedesktop.NetworkManager", path)
-            ap_prop_iface = dbus.Interface(ap_proxy, "org.freedesktop.DBus.Properties")
-            bssid = ap_prop_iface.Get("org.freedesktop.NetworkManager.AccessPoint", "HwAddress")
-
-            # Cache the BSSID
-            if not bssid in all_aps:
-                all_aps.append(bssid)
-
-            # Print the current AP's BSSID
-            if path == connected_path:
-                print "%s (%s)" % (bssid, iface)
-
-# and print out all APs the wifi devices can see
-print"\nFound APs:"
-for bssid in all_aps:
-    print bssid
-
diff --git a/examples/python/vpn.py b/examples/python/vpn.py
deleted file mode 100644
index 4b4057fc..00000000
--- a/examples/python/vpn.py
+++ /dev/null
@@ -1,152 +0,0 @@
-#!/usr/bin/python
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License along
-# with this program; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Copyright (C) 2009 Novell, Inc.
-# Copyright (C) 2009 Red Hat, Inc.
-#
-
-# Run this script without any arguments to list the available connection uuids.
-
-# The uuid of the connection to activate
-CONNECTION_UUID="ac6dc9b2-85ef-4311-83d8-add5d7db3f59"
-
-# UID to use. Note that NM only allows the owner of the connection to activate it.
-#UID=1000
-UID=0
-
-import sys
-import os
-import dbus
-from dbus.mainloop.glib import DBusGMainLoop
-import gobject
-
-DBusGMainLoop(set_as_default=True)
-
-def get_connections():
-    bus = dbus.SystemBus()
-    proxy = bus.get_object('org.freedesktop.NetworkManagerUserSettings', '/org/freedesktop/NetworkManagerSettings')
-    iface = dbus.Interface(proxy, dbus_interface='org.freedesktop.NetworkManagerSettings')
-    return iface.ListConnections()
-
-
-def get_connection_by_uuid(uuid):
-    bus = dbus.SystemBus()
-    for c in get_connections():
-        proxy = bus.get_object('org.freedesktop.NetworkManagerUserSettings', c)
-        iface = dbus.Interface(proxy, dbus_interface='org.freedesktop.NetworkManagerSettings.Connection')
-        settings = iface.GetSettings()
-        if settings['connection']['uuid'] == uuid:
-            return c
-
-    return None
-
-
-def list_uuids():
-    bus = dbus.SystemBus()
-    for c in get_connections():
-        proxy = bus.get_object('org.freedesktop.NetworkManagerUserSettings', c)
-        iface = dbus.Interface(proxy, dbus_interface='org.freedesktop.NetworkManagerSettings.Connection')
-        settings = iface.GetSettings()
-        conn = settings['connection']
-        print "%s - %s (%s)" % (conn['uuid'], conn['id'], conn['type'])
-
-
-def get_active_connection_path(uuid):
-    bus = dbus.SystemBus()
-    proxy = bus.get_object('org.freedesktop.NetworkManager', '/org/freedesktop/NetworkManager')
-    iface = dbus.Interface(proxy, dbus_interface='org.freedesktop.DBus.Properties')
-    active_connections = iface.Get('org.freedesktop.NetworkManager', 'ActiveConnections')
-    all_connections = get_connections()
-
-    for a in active_connections:
-        proxy = bus.get_object('org.freedesktop.NetworkManager', a)
-        iface = dbus.Interface(proxy, dbus_interface='org.freedesktop.DBus.Properties')
-        path = iface.Get('org.freedesktop.NetworkManager.Connection.Active', 'Connection')
-
-        proxy = bus.get_object('org.freedesktop.NetworkManagerUserSettings', path)
-        iface = dbus.Interface(proxy, dbus_interface='org.freedesktop.NetworkManagerSettings.Connection')
-        settings = iface.GetSettings()
-
-        if settings['connection']['uuid'] == uuid:
-            return a
-
-    return None
-
-
-def get_wifi_device_path():
-    bus = dbus.SystemBus()
-    proxy = bus.get_object('org.freedesktop.NetworkManager', '/org/freedesktop/NetworkManager')
-    iface = dbus.Interface(proxy, dbus_interface='org.freedesktop.NetworkManager')
-    devices = iface.GetDevices()
-    for d in devices:
-        proxy = bus.get_object('org.freedesktop.NetworkManager', d)
-        iface = dbus.Interface(proxy, dbus_interface='org.freedesktop.DBus.Properties')
-        devtype = iface.Get('org.freedesktop.NetworkManager.Device', 'DeviceType')
-        if devtype == 2:
-            return d
-    return None
-
-def activate_connection(connection_path, device_path):
-
-    def reply_handler(opath):
-    	print "Success: device activating"
-        sys.exit(0)
-
-    def error_handler(*args):
-    	print "Error activating device: %s" % args
-        sys.exit(1)
-
-    bus = dbus.SystemBus()
-    proxy = bus.get_object('org.freedesktop.NetworkManager', '/org/freedesktop/NetworkManager')
-    iface = dbus.Interface(proxy, dbus_interface='org.freedesktop.NetworkManager')
-    iface.ActivateConnection('org.freedesktop.NetworkManagerUserSettings',
-                             connection_path,
-                             device_path, 
-                             "/",
-                             reply_handler=reply_handler,
-                             error_handler=error_handler)
-
-
-# Change the UID first if required
-if UID != 0:
-    os.setuid(UID)
-
-# Are we configured?
-if not len(CONNECTION_UUID):
-    print "missing connection UUID"
-    sys.exit(0)
-
-connection_path = get_connection_by_uuid(CONNECTION_UUID)
-if not connection_path:
-    # Configured VPN connection is not known to NM, check CONNECTION_UUID.
-    print "couldn't find the connection"
-    sys.exit(1)
-
-device_path = get_wifi_device_path()
-if not device_path:
-    print "no wifi device found"
-    sys.exit(1)
-
-# Is it already activated?
-if get_active_connection_path(CONNECTION_UUID):
-    print "already connected"
-    sys.exit(0)
-
-print "Activating connection..."
-activate_connection(connection_path, device_path)
-loop = gobject.MainLoop()
-loop.run()
-