~ubuntu-branches/ubuntu/quantal/wicd/quantal

« back to all changes in this revision

Viewing changes to wicd/autoconnect.py

  • Committer: Bazaar Package Importer
  • Author(s): David Paleino
  • Date: 2009-06-22 17:59:27 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20090622175927-iax3alden0bmj6zg
Tags: 1.6.1-3
* debian/config, debian/templates updated:
  - only show users to add to netdev, skip those who are already
    members (Closes: #534138)
  - gracefully handle upgrades from previous broken versions, where
    debconf set a value of ${default} for wicd/users
    (Closes: #532112)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#!/usr/bin/python
2
2
 
 
3
""" autoconnect -- Triggers an automatic connection attempt. """
 
4
 
3
5
#
4
 
#   Copyright (C) 2007 - 2008 Adam Blackburn
5
 
#   Copyright (C) 2007 - 2008 Dan O'Reilly
 
6
#   Copyright (C) 2007 - 2009 Adam Blackburn
 
7
#   Copyright (C) 2007 - 2009 Dan O'Reilly
6
8
#
7
9
#   This program is free software; you can redistribute it and/or modify
8
10
#   it under the terms of the GNU General Public License Version 2 as
17
19
#   along with this program.  If not, see <http://www.gnu.org/licenses/>.
18
20
#
19
21
 
 
22
from wicd import dbusmanager
 
23
 
20
24
import dbus
21
25
import time
22
 
import gobject
23
26
import sys
24
27
 
25
28
if getattr(dbus, 'version', (0, 0, 0)) < (0, 80, 0):
29
32
    DBusGMainLoop(set_as_default=True)
30
33
 
31
34
try:
32
 
    bus = dbus.SystemBus()
33
 
    proxy_obj = bus.get_object('org.wicd.daemon', '/org/wicd/daemon')
34
 
    daemon = dbus.Interface(proxy_obj, 'org.wicd.daemon')
 
35
    dbusmanager.connect_to_dbus()
 
36
    daemon = dbusmanager.get_interface('daemon')
 
37
    wireless = dbusmanager.get_interface('wireless')
35
38
except Exception, e:
36
39
    print>>sys.stderr, "Exception caught: %s" % str(e)
37
40
    print>>sys.stderr, 'Could not connect to daemon.'
38
41
    sys.exit(1)
39
42
 
40
43
def handler(*args):
41
 
    loop.quit()
42
 
 
 
44
    pass
43
45
def error_handler(*args):
44
46
    print>>sys.stderr, 'Async error autoconnecting.'
45
47
    sys.exit(3)
46
48
 
47
49
if __name__ == '__main__':
48
50
    try:
49
 
        time.sleep(3)
 
51
        time.sleep(2)
50
52
        daemon.SetSuspend(False)
51
53
        if not daemon.CheckIfConnecting():
52
 
            daemon.SetForcedDisconnect(False)
53
 
            daemon.AutoConnect(True, reply_handler=handler, error_handler=handler)
 
54
            daemon.AutoConnect(True, reply_handler=handler, 
 
55
                               error_handler=error_handler)
54
56
    except Exception, e:
55
57
        print>>sys.stderr, "Exception caught: %s" % str(e)
56
58
        print>>sys.stderr, 'Error autoconnecting.'