1
0
mirror of https://github.com/gryf/wicd.git synced 2026-02-19 16:35:46 +01:00

Use dbusmanager in autoconnect.py

This commit is contained in:
Dan O'Reilly
2009-01-15 01:22:40 -05:00
parent d84912aaad
commit fcf01b12b3

View File

@@ -17,6 +17,8 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
# #
from wicd import dbusmanager
import dbus import dbus
import time import time
import gobject import gobject
@@ -29,9 +31,9 @@ else:
DBusGMainLoop(set_as_default=True) DBusGMainLoop(set_as_default=True)
try: try:
bus = dbus.SystemBus() dbusmanager.connect_to_dbus()
proxy_obj = bus.get_object('org.wicd.daemon', '/org/wicd/daemon') daemon = dbusmanager.get_interface('daemon')
daemon = dbus.Interface(proxy_obj, 'org.wicd.daemon') wireless = dbusmanager.get_interface('wireless')
except Exception, e: except Exception, e:
print>>sys.stderr, "Exception caught: %s" % str(e) print>>sys.stderr, "Exception caught: %s" % str(e)
print>>sys.stderr, 'Could not connect to daemon.' print>>sys.stderr, 'Could not connect to daemon.'
@@ -46,10 +48,10 @@ def error_handler(*args):
if __name__ == '__main__': if __name__ == '__main__':
try: try:
time.sleep(3) time.sleep(2)
wireless.Scan()
daemon.SetSuspend(False) daemon.SetSuspend(False)
if not daemon.CheckIfConnecting(): if not daemon.CheckIfConnecting():
daemon.SetForcedDisconnect(False)
daemon.AutoConnect(True, reply_handler=handler, error_handler=handler) daemon.AutoConnect(True, reply_handler=handler, error_handler=handler)
except Exception, e: except Exception, e:
print>>sys.stderr, "Exception caught: %s" % str(e) print>>sys.stderr, "Exception caught: %s" % str(e)