~ubuntu-branches/ubuntu/oneiric/wicd/oneiric-updates

« back to all changes in this revision

Viewing changes to wicd/monitor.py

  • Committer: Bazaar Package Importer
  • Author(s): David Paleino
  • Date: 2008-12-24 17:37:13 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20081224173713-l9o484a46w2bq2eb
Tags: 1.5.7-1
* New upstream release (Closes: #503737)
* debian/control:
  - added some runtime dependencies (not really, but used by most 
    users) to wicd (Closes: #503739)
  - added Conflicts: network-manager (Closes: #509051)
  - added Suggests on pm-utils, since we now also have those
    functionalities
  - update Vcs-* and Maintainer fields to reflect injection into
    PAPT
* debian/postrm added:
  - removes runtime-generated files (Closes: #503747)
* debian/patches:
  - 02-fix_logfile_perms.patch added, sets permissions of 
    /var/log/wicd/wicd.log to root:adm (Closes: #503749)
  - 03-fix_lintian_manpage_warning.patch added, gives a more
    meaningful whatis entry
* debian/rules:
  - get-orig-source target to ease upstream tarball fetch
  - ensure right permissions are set in install target
  - using dh7-style rules
* debian/README.source added
* debian/docs removed
* debian/copyright fixed:
  - added copyright year to in/man*
  - removed useless escaping of '=' in filenames
  - fixed pointer to GPL-2

Show diffs side-by-side

added added

removed removed

Lines of Context:
57
57
        self.network = ''
58
58
        self.tried_reconnect = False
59
59
        self.connection_lost_counter = 0
 
60
        self.dbus_error_count = 0
60
61
        self.last_state = misc.NOT_CONNECTED
61
62
        self.reconnecting = False
62
63
        self.reconnect_tries = 0
113
114
            # If we haven't gotten any signal 4 runs in a row (12 seconds),
114
115
            # try to reconnect.
115
116
            self.connection_lost_counter += 1
116
 
            # print self.connection_lost_counter
 
117
            #print self.connection_lost_counter
117
118
            if self.connection_lost_counter >= 4:
 
119
                print "Connection lost for too long, setting status to disconnected."
118
120
                self.connection_lost_counter = 0
119
121
                return False
120
122
        else:  # If we have a signal, reset the counter
149
151
                return True
150
152
 
151
153
            # Determine what our current state is.
 
154
            # Are we currently connecting?
 
155
            if daemon.CheckIfConnecting():
 
156
                state = misc.CONNECTING
 
157
                self.update_state(state)
 
158
                return True
 
159
                
152
160
            # Check for wired.
153
161
            wired_ip = wired.GetWiredIP()
154
162
            wired_found = self.check_for_wired_connection(wired_ip)
164
172
            if wireless_found:
165
173
                self.update_state(misc.WIRELESS, wifi_ip=wifi_ip)
166
174
                return True
167
 
                
168
 
            # Are we currently connecting?
169
 
            if daemon.CheckIfConnecting():
170
 
                state = misc.CONNECTING
171
 
            else:  # No connection at all.
172
 
                state = misc.NOT_CONNECTED
173
 
                if self.last_state == misc.WIRELESS:
174
 
                    from_wireless = True
175
 
                else:
176
 
                    from_wireless = False
177
 
                self.auto_reconnect(from_wireless)
 
175
            
 
176
            state = misc.NOT_CONNECTED
 
177
            if self.last_state == misc.WIRELESS:
 
178
                from_wireless = True
 
179
            else:
 
180
                from_wireless = False
 
181
            self.auto_reconnect(from_wireless)
178
182
            self.update_state(state)
 
183
            self.dbus_error_count = 0
179
184
        except dbus.exceptions.DBusException, e:
180
185
            print 'Ignoring DBus Error: ' + str(e)
 
186
            self.dbus_error_count += 1
 
187
            if self.dbus_error_count > 5:
 
188
                raise dbus.exceptions.DBusException(e)
181
189
        finally:
182
190
            return True
183
191
 
192
200
            if wired.CheckIfWiredConnecting():
193
201
                info = ["wired"]
194
202
            else:
195
 
                info = ["wireless", wireless.GetCurrentNetwork(self.iwconfig)]
 
203
                info = ["wireless", str(wireless.GetCurrentNetwork(self.iwconfig))]
196
204
        elif state == misc.WIRELESS:
197
205
            self.reconnect_tries = 0
198
 
            info = [wifi_ip, wireless.GetCurrentNetwork(self.iwconfig),
 
206
            info = [str(wifi_ip), str(wireless.GetCurrentNetwork(self.iwconfig)),
199
207
                    str(wireless.GetPrintableSignalStrength(self.iwconfig)),
200
208
                    str(wireless.GetCurrentNetworkID(self.iwconfig))]
201
209
        elif state == misc.WIRED:
202
210
            self.reconnect_tries = 0
203
 
            info = [wired_ip]
 
211
            info = [str(wired_ip)]
204
212
        else:
205
213
            print 'ERROR: Invalid state!'
206
214
            return True
226
234
        
227
235
        # Some checks to keep reconnect retries from going crazy.
228
236
        if self.reconnect_tries > 2 and \
229
 
           time.time() - self.last_reconnect_time < 30:
 
237
           (time.time() - self.last_reconnect_time) < 300:
230
238
            return
231
239
 
232
240
        self.reconnecting = True