Restarting VPN Connections



I am writing a (python) script to restart VPN connections if they shut
down.  Here's what I have:

#!/usr/bin/env python

import gobject, dbus
from dbus.mainloop.glib import DBusGMainLoop

CONNECTED = 5
DISCONNECTED = 7

DBusGMainLoop(set_as_default=True)
system_bus = dbus.SystemBus()

def vpn_connection_handler(*args, **kwargs):

    state = args[0] 
    if state == CONNECTED:
        print "connected"
    elif state == DISCONNECTED:
        print "disconnected"
        ppp0 = system_bus.get_object('org.freedesktop.NetworkManager',
'/org/freedesktop/NetworkManager/VPN/Plugin')
        ppp0_dev_iface = dbus.Interface(ppp0,
dbus_interface='org.freedesktop.NetworkManager.VPN.Plugin')
	value = []
        props = ppp0_dev_iface.Connect({"ppp0": {"ppp0": value}})
	print props

system_bus.add_signal_receiver(vpn_connection_handler,
dbus_interface="org.freedesktop.NetworkManager.VPN.Connection",
signal_name="VpnStateChanged")
gobject.MainLoop().run()



If you try it, you'll notice that the reconnection part doesn't work.
Little help?

Thanks!

Attachment: signature.asc
Description: This is a digitally signed message part



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]