mirror of
https://github.com/gryf/wicd.git
synced 2026-03-07 01:55:49 +01:00
Make sure autoconnect.py never blocks
Tweak configmanager to not write a default value unless one is specified in the get call.
This commit is contained in:
@@ -20,25 +20,23 @@
|
|||||||
import dbus
|
import dbus
|
||||||
import time
|
import time
|
||||||
import gobject
|
import gobject
|
||||||
|
import sys
|
||||||
from dbus.mainloop.glib import DBusGMainLoop
|
from dbus.mainloop.glib import DBusGMainLoop
|
||||||
|
|
||||||
DBusGMainLoop(set_as_default=True)
|
DBusGMainLoop(set_as_default=True)
|
||||||
bus = dbus.SystemBus()
|
bus = dbus.SystemBus()
|
||||||
proxy_obj = bus.get_object('org.wicd.daemon', '/org/wicd/daemon')
|
proxy_obj = bus.get_object('org.wicd.daemon', '/org/wicd/daemon')
|
||||||
daemon = dbus.Interface(proxy_obj, 'org.wicd.daemon')
|
daemon = dbus.Interface(proxy_obj, 'org.wicd.daemon')
|
||||||
|
loop = gobject.MainLoop()
|
||||||
|
|
||||||
def reply_handle():
|
|
||||||
loop.quit()
|
def handler(*args):
|
||||||
def error_handle(e):
|
|
||||||
loop.quit()
|
loop.quit()
|
||||||
|
|
||||||
print daemon.Hello()
|
print daemon.Hello()
|
||||||
time.sleep(3)
|
time.sleep(3)
|
||||||
daemon.SetSuspend(False)
|
daemon.SetSuspend(False)
|
||||||
if not daemon.CheckIfConnecting():
|
if not daemon.CheckIfConnecting():
|
||||||
print daemon.AutoConnect(True, reply_handler=reply_handle,
|
|
||||||
error_handler=error_handle)
|
|
||||||
daemon.SetForcedDisconnect(False)
|
daemon.SetForcedDisconnect(False)
|
||||||
|
daemon.AutoConnect(True, reply_handler=handler, error_handler=handler)
|
||||||
|
|
||||||
loop = gobject.MainLoop()
|
|
||||||
loop.run()
|
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ class ConfigManager(RawConfigParser):
|
|||||||
""" Calls the set_option method. """
|
""" Calls the set_option method. """
|
||||||
self.set_option(*args, **kargs)
|
self.set_option(*args, **kargs)
|
||||||
|
|
||||||
def get_option(self, section, option, default=None):
|
def get_option(self, section, option, default="__None__"):
|
||||||
""" Wrapper around ConfigParser.get.
|
""" Wrapper around ConfigParser.get.
|
||||||
|
|
||||||
Automatically adds any missing sections, adds the ability
|
Automatically adds any missing sections, adds the ability
|
||||||
@@ -82,10 +82,13 @@ class ConfigManager(RawConfigParser):
|
|||||||
if default:
|
if default:
|
||||||
print ''.join(['found ', option, ' in configuration ', ret])
|
print ''.join(['found ', option, ' in configuration ', ret])
|
||||||
else:
|
else:
|
||||||
print ''.join(['did not find ', option,
|
if default != "__None__":
|
||||||
|
print ''.join(['did not find ', option,
|
||||||
' in configuration, setting default ', str(default)])
|
' in configuration, setting default ', str(default)])
|
||||||
self.set(section, option, str(default), save=True)
|
self.set(section, option, str(default), save=True)
|
||||||
ret = default
|
ret = default
|
||||||
|
else:
|
||||||
|
ret = None
|
||||||
|
|
||||||
# Try to intelligently handle the type of the return value.
|
# Try to intelligently handle the type of the return value.
|
||||||
try:
|
try:
|
||||||
|
|||||||
Reference in New Issue
Block a user