Merge lp:~fox1991/wicd/fox into lp:wicd/1.6

Proposed by fox91
Status: Merged
Merged at revision: 576
Proposed branch: lp:~fox1991/wicd/fox
Merge into: lp:wicd/1.6
Diff against target: 395 lines (+157/-156)
4 files modified
cli/wicd-cli.py (+149/-147)
curses/wicd-curses.py (+3/-6)
gtk/gui.py (+3/-2)
wicd/wicd-daemon.py (+2/-1)
To merge this branch: bzr merge lp:~fox1991/wicd/fox
Reviewer Review Type Date Requested Status
David Paleino Needs Information
Review via email: mp+66727@code.launchpad.net

Description of the change

I fixed a little bug in the clients (it's a silly thing but i didn't like it):
when you connect to a wireless network sometimes the statusbar message was a bit confusing, instead of showing <essid>: <connecting status> it showed None or another essid instead of the one of the network it was connecting to.

Then i noticed i little bug in the cli client, if using -c without -n it raised an exception.
in the cli-client i changed tabs into 4 spaces

To post a comment you must log in.
Revision history for this message
David Paleino (dpaleino) wrote :

Hello,

I merged your rev. 572, and will soon push it.

However, I don't quite understand your 573. Ok, there might be some mixed tabs-and-spaces indentation, but that would've been best addressed in a separate commit. If there's a real fix, it's hidden in that huge diff.

Would you mind pointing out the actual fix? :)

Thanks,
David

review: Needs Information
Revision history for this message
fox91 (fox1991) wrote :

573 is a fix for cli/wicd-cli.py and a conversion from tabs to four spaces (there was a mix!).

The fix is in these lines:

197 last = None
198 if check is not None:
199 while check():

If check is None an exception was raised (reproducible with launching the script with incorrect parameters)

Revision history for this message
David Paleino (dpaleino) wrote :

On Mon, 08 Aug 2011 09:22:17 -0000, fox91 wrote:

> 573 is a fix for cli/wicd-cli.py and a conversion from tabs to four spaces
> (there was a mix!).
>
> The fix is in these lines:
>
> 197 last = None
> 198 if check is not None:
> 199 while check():
>
> If check is None an exception was raised (reproducible with launching the
> script with incorrect parameters)

Ah, I see.

Would you mind making a branch with those two things (fix + tabs→spaces) fixed
in different commits? That would be cleaner for the repository history (and
easier for me, so that I can just merge your new branch).

Thank you,
David

--
 . ''`. Debian developer | http://wiki.debian.org/DavidPaleino
 : :' : Linuxer #334216 --|-- http://www.hanskalabs.net/
 `. `'` GPG: 1392B174 ----|---- http://deb.li/dapal
   `- 2BAB C625 4E66 E7B8 450A C3E1 E6AA 9017 1392 B174

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'cli/wicd-cli.py'
2--- cli/wicd-cli.py 2010-05-29 09:32:34 +0000
3+++ cli/wicd-cli.py 2011-07-03 18:57:27 +0000
4@@ -31,17 +31,17 @@
5
6 bus = dbus.SystemBus()
7 try:
8- daemon = dbus.Interface(bus.get_object('org.wicd.daemon', '/org/wicd/daemon'),
9- 'org.wicd.daemon')
10- wireless = dbus.Interface(bus.get_object('org.wicd.daemon', '/org/wicd/daemon/wireless'),
11- 'org.wicd.daemon.wireless')
12- wired = dbus.Interface(bus.get_object('org.wicd.daemon', '/org/wicd/daemon/wired'),
13- 'org.wicd.daemon.wired')
14- config = dbus.Interface(bus.get_object('org.wicd.daemon', '/org/wicd/daemon/config'),
15- 'org.wicd.daemon.config')
16+ daemon = dbus.Interface(bus.get_object('org.wicd.daemon', '/org/wicd/daemon'),
17+ 'org.wicd.daemon')
18+ wireless = dbus.Interface(bus.get_object('org.wicd.daemon', '/org/wicd/daemon/wireless'),
19+ 'org.wicd.daemon.wireless')
20+ wired = dbus.Interface(bus.get_object('org.wicd.daemon', '/org/wicd/daemon/wired'),
21+ 'org.wicd.daemon.wired')
22+ config = dbus.Interface(bus.get_object('org.wicd.daemon', '/org/wicd/daemon/config'),
23+ 'org.wicd.daemon.config')
24 except dbus.DBusException:
25- print 'Error: Could not connect to the daemon. Please make sure it is running.'
26- sys.exit(3)
27+ print 'Error: Could not connect to the daemon. Please make sure it is running.'
28+ sys.exit(3)
29
30 parser = optparse.OptionParser()
31
32@@ -67,174 +67,176 @@
33 op_performed = False
34
35 if not (options.wireless or options.wired):
36- print "Please use --wireless or --wired to specify " + \
37- "the type of connection to operate on."
38+ print "Please use --wireless or --wired to specify " + \
39+ "the type of connection to operate on."
40
41 # functions
42 def is_valid_wireless_network_id(network_id):
43- if not (network_id >= 0 \
44- and network_id < wireless.GetNumberOfNetworks()):
45- print 'Invalid wireless network identifier.'
46- sys.exit(1)
47+ if not (network_id >= 0 \
48+ and network_id < wireless.GetNumberOfNetworks()):
49+ print 'Invalid wireless network identifier.'
50+ sys.exit(1)
51
52 def is_valid_wired_network_id(network_id):
53- num = len(wired.GetWiredProfileList())
54- if not (network_id < num and \
55- network_id >= 0):
56- print 'Invalid wired network identifier.'
57- sys.exit(4)
58+ num = len(wired.GetWiredProfileList())
59+ if not (network_id < num and \
60+ network_id >= 0):
61+ print 'Invalid wired network identifier.'
62+ sys.exit(4)
63
64 def is_valid_wired_network_profile(profile_name):
65- if not profile_name in wired.GetWiredProfileList():
66- print 'Profile of that name does not exist.'
67- sys.exit(5)
68+ if not profile_name in wired.GetWiredProfileList():
69+ print 'Profile of that name does not exist.'
70+ sys.exit(5)
71
72 if options.scan and options.wireless:
73- # synchronized scan
74- wireless.Scan(True)
75- op_performed = True
76+ # synchronized scan
77+ wireless.Scan(True)
78+ op_performed = True
79
80 if options.load_profile and options.wired:
81- is_valid_wired_network_profile(options.name)
82- config.ReadWiredNetworkProfile(options.name)
83- op_performed = True
84+ is_valid_wired_network_profile(options.name)
85+ config.ReadWiredNetworkProfile(options.name)
86+ op_performed = True
87
88 if options.list_networks:
89- if options.wireless:
90- print '#\tBSSID\t\t\tChannel\tESSID'
91- for network_id in range(0, wireless.GetNumberOfNetworks()):
92- print '%s\t%s\t%s\t%s' % (network_id,
93- wireless.GetWirelessProperty(network_id, 'bssid'),
94- wireless.GetWirelessProperty(network_id, 'channel'),
95- wireless.GetWirelessProperty(network_id, 'essid'))
96- elif options.wired:
97- print '#\tProfile name'
98- id = 0
99- for profile in wired.GetWiredProfileList():
100- print '%s\t%s' % (id, profile)
101- id += 1
102- op_performed = True
103+ if options.wireless:
104+ print '#\tBSSID\t\t\tChannel\tESSID'
105+ for network_id in range(0, wireless.GetNumberOfNetworks()):
106+ print '%s\t%s\t%s\t%s' % (network_id,
107+ wireless.GetWirelessProperty(network_id, 'bssid'),
108+ wireless.GetWirelessProperty(network_id, 'channel'),
109+ wireless.GetWirelessProperty(network_id, 'essid'))
110+ elif options.wired:
111+ print '#\tProfile name'
112+ id = 0
113+ for profile in wired.GetWiredProfileList():
114+ print '%s\t%s' % (id, profile)
115+ id += 1
116+ op_performed = True
117
118 if options.network_details:
119- if options.wireless:
120- if options.network >= 0:
121- is_valid_wireless_network_id(options.network)
122- network_id = options.network
123- else:
124- network_id = wireless.GetCurrentNetworkID(0)
125- is_valid_wireless_network_id(network_id)
126- # we're connected to a network, print IP
127- print "IP: %s" % wireless.GetWirelessIP(0)
128+ if options.wireless:
129+ if options.network >= 0:
130+ is_valid_wireless_network_id(options.network)
131+ network_id = options.network
132+ else:
133+ network_id = wireless.GetCurrentNetworkID(0)
134+ is_valid_wireless_network_id(network_id)
135+ # we're connected to a network, print IP
136+ print "IP: %s" % wireless.GetWirelessIP(0)
137
138- print "Essid: %s" % wireless.GetWirelessProperty(network_id, "essid")
139- print "Bssid: %s" % wireless.GetWirelessProperty(network_id, "bssid")
140- if wireless.GetWirelessProperty(network_id, "encryption"):
141- print "Encryption: On"
142- print "Encryption Method: %s" % \
143- wireless.GetWirelessProperty(network_id, "encryption_method")
144- else:
145- print "Encryption: Off"
146- print "Quality: %s" % wireless.GetWirelessProperty(network_id, "quality")
147- print "Mode: %s" % wireless.GetWirelessProperty(network_id, "mode")
148- print "Channel: %s" % wireless.GetWirelessProperty(network_id, "channel")
149- print "Bit Rates: %s" % wireless.GetWirelessProperty(network_id, "bitrates")
150- op_performed = True
151+ print "Essid: %s" % wireless.GetWirelessProperty(network_id, "essid")
152+ print "Bssid: %s" % wireless.GetWirelessProperty(network_id, "bssid")
153+ if wireless.GetWirelessProperty(network_id, "encryption"):
154+ print "Encryption: On"
155+ print "Encryption Method: %s" % \
156+ wireless.GetWirelessProperty(network_id, "encryption_method")
157+ else:
158+ print "Encryption: Off"
159+ print "Quality: %s" % wireless.GetWirelessProperty(network_id, "quality")
160+ print "Mode: %s" % wireless.GetWirelessProperty(network_id, "mode")
161+ print "Channel: %s" % wireless.GetWirelessProperty(network_id, "channel")
162+ print "Bit Rates: %s" % wireless.GetWirelessProperty(network_id, "bitrates")
163+ op_performed = True
164
165 # network properties
166
167 if options.network_property:
168- options.network_property = options.network_property.lower()
169- if options.wireless:
170- if options.network >= 0:
171- is_valid_wireless_network_id(options.network)
172- network_id = options.network
173- else:
174- network_id = wireless.GetCurrentNetworkID(0)
175- is_valid_wireless_network_id(network_id)
176- if not options.set_to:
177- print wireless.GetWirelessProperty(network_id, options.network_property)
178- else:
179- wireless.SetWirelessProperty(network_id, \
180- options.network_property, options.set_to)
181- elif options.wired:
182- if not options.set_to:
183- print wired.GetWiredProperty(options.network_property)
184- else:
185- wired.SetWiredProperty(options.network_property, options.set_to)
186- op_performed = True
187+ options.network_property = options.network_property.lower()
188+ if options.wireless:
189+ if options.network >= 0:
190+ is_valid_wireless_network_id(options.network)
191+ network_id = options.network
192+ else:
193+ network_id = wireless.GetCurrentNetworkID(0)
194+ is_valid_wireless_network_id(network_id)
195+ if not options.set_to:
196+ print wireless.GetWirelessProperty(network_id, options.network_property)
197+ else:
198+ wireless.SetWirelessProperty(network_id, \
199+ options.network_property, options.set_to)
200+ elif options.wired:
201+ if not options.set_to:
202+ print wired.GetWiredProperty(options.network_property)
203+ else:
204+ wired.SetWiredProperty(options.network_property, options.set_to)
205+ op_performed = True
206
207 if options.disconnect:
208- daemon.Disconnect()
209- if options.wireless:
210- if wireless.GetCurrentNetworkID(0) > -1:
211- print "Disconnecting from %s on %s" % (wireless.GetCurrentNetwork(0),
212- wireless.DetectWirelessInterface())
213- elif options.wired:
214- if wired.CheckPluggedIn():
215- print "Disconnecting from wired connection on %s" % wired.DetectWiredInterface()
216- op_performed = True
217+ daemon.Disconnect()
218+ if options.wireless:
219+ if wireless.GetCurrentNetworkID(0) > -1:
220+ print "Disconnecting from %s on %s" % (wireless.GetCurrentNetwork(0),
221+ wireless.DetectWirelessInterface())
222+ elif options.wired:
223+ if wired.CheckPluggedIn():
224+ print "Disconnecting from wired connection on %s" % wired.DetectWiredInterface()
225+ op_performed = True
226
227 if options.connect:
228- if options.wireless and options.network > -1:
229- is_valid_wireless_network_id(options.network)
230- name = wireless.GetWirelessProperty(options.network, 'essid')
231- encryption = wireless.GetWirelessProperty(options.network, 'enctype')
232- print "Connecting to %s with %s on %s" % (name, encryption,
233- wireless.DetectWirelessInterface())
234- wireless.ConnectWireless(options.network)
235-
236- check = lambda: wireless.CheckIfWirelessConnecting()
237- message = lambda: wireless.CheckWirelessConnectingMessage()
238- elif options.wired:
239- print "Connecting to wired connection on %s" % wired.DetectWiredInterface()
240- wired.ConnectWired()
241-
242- check = lambda: wired.CheckIfWiredConnecting()
243- message = lambda: wired.CheckWiredConnectingMessage()
244-
245- # update user on what the daemon is doing
246- last = None
247- while check():
248- next = message()
249- if next != last:
250- # avoid a race condition where status is updated to "done" after the
251- # loop check
252- if next == "done":
253- break
254- print "%s..." % next.replace("_", " ")
255- last = next
256- print "done!"
257- op_performed = True
258+ check = None
259+ if options.wireless and options.network > -1:
260+ is_valid_wireless_network_id(options.network)
261+ name = wireless.GetWirelessProperty(options.network, 'essid')
262+ encryption = wireless.GetWirelessProperty(options.network, 'enctype')
263+ print "Connecting to %s with %s on %s" % (name, encryption,
264+ wireless.DetectWirelessInterface())
265+ wireless.ConnectWireless(options.network)
266+
267+ check = lambda: wireless.CheckIfWirelessConnecting()
268+ message = lambda: wireless.CheckWirelessConnectingMessage()[1]
269+ elif options.wired:
270+ print "Connecting to wired connection on %s" % wired.DetectWiredInterface()
271+ wired.ConnectWired()
272+
273+ check = lambda: wired.CheckIfWiredConnecting()
274+ message = lambda: wired.CheckWiredConnectingMessage()
275+
276+ # update user on what the daemon is doing
277+ last = None
278+ if check is not None:
279+ while check():
280+ next = message()
281+ if next != last:
282+ # avoid a race condition where status is updated to "done" after the
283+ # loop check
284+ if next == "done":
285+ break
286+ print "%s..." % next.replace("_", " ")
287+ last = next
288+ print "done!"
289+ op_performed = True
290
291 # pretty print optional and required properties
292 def str_properties(prop):
293- if len(prop) == 0:
294- return "None"
295- else:
296- return ', '.join("%s (%s)" % (x[0], x[1].replace("_", " ")) for x in type['required'])
297+ if len(prop) == 0:
298+ return "None"
299+ else:
300+ return ', '.join("%s (%s)" % (x[0], x[1].replace("_", " ")) for x in type['required'])
301
302 if options.wireless and options.list_encryption_types:
303- et = misc.LoadEncryptionMethods()
304- # print 'Installed encryption templates:'
305- print '%s\t%-20s\t%s' % ('#', 'Name', 'Description')
306- id = 0
307- for type in et:
308- print '%s\t%-20s\t%s' % (id, type['type'], type['name'])
309- print ' Req: %s' % str_properties(type['required'])
310- print '---'
311- # don't print optionals (yet)
312- #print ' Opt: %s' % str_properties(type['optional'])
313- id += 1
314- op_performed = True
315+ et = misc.LoadEncryptionMethods()
316+ # print 'Installed encryption templates:'
317+ print '%s\t%-20s\t%s' % ('#', 'Name', 'Description')
318+ id = 0
319+ for type in et:
320+ print '%s\t%-20s\t%s' % (id, type['type'], type['name'])
321+ print ' Req: %s' % str_properties(type['required'])
322+ print '---'
323+ # don't print optionals (yet)
324+ #print ' Opt: %s' % str_properties(type['optional'])
325+ id += 1
326+ op_performed = True
327
328 if options.save and options.network > -1:
329- if options.wireless:
330- is_valid_wireless_network_id(options.network)
331- config.SaveWirelessNetworkProfile(options.network)
332- elif options.wired:
333- config.SaveWiredNetworkProfile(options.name)
334- op_performed = True
335+ if options.wireless:
336+ is_valid_wireless_network_id(options.network)
337+ config.SaveWirelessNetworkProfile(options.network)
338+ elif options.wired:
339+ config.SaveWiredNetworkProfile(options.name)
340+ op_performed = True
341
342 if not op_performed:
343- print "No operations performed."
344+ print "No operations performed."
345
346
347=== modified file 'curses/wicd-curses.py'
348--- curses/wicd-curses.py 2010-06-09 17:20:53 +0000
349+++ curses/wicd-curses.py 2011-07-03 18:57:27 +0000
350@@ -733,12 +733,9 @@
351 iwconfig = wireless.GetIwconfig()
352 else:
353 iwconfig = ''
354- # set_status is rigged to return false when it is not
355- # connecting to anything, so this should work.
356- return self.set_status(wireless.GetCurrentNetwork(iwconfig) +
357- ': ' +
358- language[str(wireless.CheckWirelessConnectingMessage())],
359- True)
360+ essid, stat = wireless.CheckWirelessConnectingMessage()
361+ return self.set_status("%s: %s" % (essid, language[str(stat)]),
362+ True)
363 if wired_connecting:
364 return self.set_status( language['wired_network'] +
365 ': ' +
366
367=== modified file 'gtk/gui.py'
368--- gtk/gui.py 2010-05-29 09:32:37 +0000
369+++ gtk/gui.py 2011-07-03 18:57:27 +0000
370@@ -446,8 +446,9 @@
371 if self.statusID:
372 gobject.idle_add(self.status_bar.remove_message, 1, self.statusID)
373 if info[0] == "wireless":
374- gobject.idle_add(self.set_status, str(info[1]) + ': ' +
375- language[str(wireless.CheckWirelessConnectingMessage())])
376+ essid, stat = wireless.CheckWirelessConnectingMessage()
377+ gobject.idle_add(self.set_status, "%s: %s" % (essid,
378+ language[str(stat)]))
379 elif info[0] == "wired":
380 gobject.idle_add(self.set_status, language['wired_network'] + ': ' +
381 language[str(wired.CheckWiredConnectingMessage())])
382
383=== modified file 'wicd/wicd-daemon.py'
384--- wicd/wicd-daemon.py 2010-12-23 19:12:58 +0000
385+++ wicd/wicd-daemon.py 2011-07-03 18:57:27 +0000
386@@ -1201,8 +1201,9 @@
387 def CheckWirelessConnectingMessage(self):
388 """ Returns the wireless interface's status message. """
389 if not self.wifi.connecting_thread == None:
390+ essid = self.wifi.connecting_thread.network["essid"]
391 stat = self.wifi.connecting_thread.GetStatus()
392- return stat
393+ return essid, stat
394 else:
395 return False
396

Subscribers

People subscribed via source and target branches

to status/vote changes: