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:
@@ -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)
|
||||||
|
|||||||
Reference in New Issue
Block a user