mirror of
https://github.com/gryf/wicd.git
synced 2025-12-27 00:42:31 +01:00
Merged autoconnect.py and suspend.py changes from trunk (fixes for
the pm-utils sleep hook usage).
This commit is contained in:
@@ -1,8 +1,8 @@
|
|||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
|
|
||||||
#
|
#
|
||||||
# Copyright (C) 2007 Adam Blackburn
|
# Copyright (C) 2007 - 2008 Adam Blackburn
|
||||||
# Copyright (C) 2007 Dan O'Reilly
|
# Copyright (C) 2007 - 2008 Dan O'Reilly
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# This program is free software; you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License Version 2 as
|
# it under the terms of the GNU General Public License Version 2 as
|
||||||
@@ -21,22 +21,37 @@ import dbus
|
|||||||
import time
|
import time
|
||||||
import gobject
|
import gobject
|
||||||
import sys
|
import sys
|
||||||
from dbus.mainloop.glib import DBusGMainLoop
|
|
||||||
|
|
||||||
DBusGMainLoop(set_as_default=True)
|
if getattr(dbus, 'version', (0, 0, 0)) < (0, 80, 0):
|
||||||
bus = dbus.SystemBus()
|
import dbus.glib
|
||||||
proxy_obj = bus.get_object('org.wicd.daemon', '/org/wicd/daemon')
|
else:
|
||||||
daemon = dbus.Interface(proxy_obj, 'org.wicd.daemon')
|
from dbus.mainloop.glib import DBusGMainLoop
|
||||||
loop = gobject.MainLoop()
|
DBusGMainLoop(set_as_default=True)
|
||||||
|
|
||||||
|
try:
|
||||||
|
bus = dbus.SystemBus()
|
||||||
|
proxy_obj = bus.get_object('org.wicd.daemon', '/org/wicd/daemon')
|
||||||
|
daemon = dbus.Interface(proxy_obj, 'org.wicd.daemon')
|
||||||
|
except Exception, e:
|
||||||
|
print>>sys.stderr, "Exception caught: %s" % str(e)
|
||||||
|
print>>sys.stderr, 'Could not connect to daemon.'
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
def handler(*args):
|
def handler(*args):
|
||||||
loop.quit()
|
loop.quit()
|
||||||
|
|
||||||
print daemon.Hello()
|
def error_handler(*args):
|
||||||
time.sleep(3)
|
print>>sys.stderr, 'Async error autoconnecting.'
|
||||||
daemon.SetSuspend(False)
|
sys.exit(3)
|
||||||
if not daemon.CheckIfConnecting():
|
|
||||||
daemon.SetForcedDisconnect(False)
|
|
||||||
daemon.AutoConnect(True, reply_handler=handler, error_handler=handler)
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
try:
|
||||||
|
time.sleep(3)
|
||||||
|
daemon.SetSuspend(False)
|
||||||
|
if not daemon.CheckIfConnecting():
|
||||||
|
daemon.SetForcedDisconnect(False)
|
||||||
|
daemon.AutoConnect(True, reply_handler=handler, error_handler=handler)
|
||||||
|
except Exception, e:
|
||||||
|
print>>sys.stderr, "Exception caught: %s" % str(e)
|
||||||
|
print>>sys.stderr, 'Error autoconnecting.'
|
||||||
|
sys.exit(2)
|
||||||
|
|||||||
@@ -2,14 +2,14 @@
|
|||||||
|
|
||||||
""" Suspends the wicd daemon.
|
""" Suspends the wicd daemon.
|
||||||
|
|
||||||
Sets a flag in the daemon that will stop it from monitoring network status.
|
Sets a flag in the daemon that will stop it from monitoring networkg status.
|
||||||
Used for when a laptop enters hibernation/suspension.
|
Used for when a laptop enters hibernation/suspension.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
#
|
#
|
||||||
# Copyright (C) 2007 Adam Blackburn
|
# Copyright (C) 2007 - 2008 Adam Blackburn
|
||||||
# Copyright (C) 2007 Dan O'Reilly
|
# Copyright (C) 2007 - 2008 Dan O'Reilly
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# This program is free software; you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License Version 2 as
|
# it under the terms of the GNU General Public License Version 2 as
|
||||||
@@ -26,13 +26,17 @@ Used for when a laptop enters hibernation/suspension.
|
|||||||
|
|
||||||
import dbus
|
import dbus
|
||||||
import dbus.service
|
import dbus.service
|
||||||
|
import sys
|
||||||
|
|
||||||
try:
|
try:
|
||||||
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')
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
print "Exception caught: %s" % str(e)
|
print>>sys.stderr, "Exception caught: %s" % str(e)
|
||||||
|
print>>sys.stderr, 'Could not connect to daemon.'
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
@@ -41,5 +45,7 @@ if __name__ == '__main__':
|
|||||||
daemon.SetForcedDisconnect(False)
|
daemon.SetForcedDisconnect(False)
|
||||||
daemon.SetSuspend(True)
|
daemon.SetSuspend(True)
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
print "Exception caught: %s" % str(e)
|
print>>sys.stderr, "Exception caught: %s" % str(e)
|
||||||
|
print>>sys.stderr, 'Error setting suspend.'
|
||||||
|
sys.exit(2)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user