Merge lp:~brendan-donegan/checkbox/bug1247141 into lp:checkbox

Proposed by Brendan Donegan
Status: Work in progress
Proposed branch: lp:~brendan-donegan/checkbox/bug1247141
Merge into: lp:checkbox
Diff against target: 47 lines (+16/-3)
2 files modified
checkbox-old/debian/changelog (+2/-1)
checkbox-old/scripts/network (+14/-2)
To merge this branch: bzr merge lp:~brendan-donegan/checkbox/bug1247141
Reviewer Review Type Date Requested Status
Checkbox Developers Pending
Review via email: mp+193819@code.launchpad.net

Description of the change

Wireless cards do not show the interface speed in /sys/class/net/<interface>/speed, so instead we need to find it from iwconfig. This merge request updates the Interface class of the network script to do this.

To post a comment you must log in.

Unmerged revisions

2487. By Brendan Donegan

scripts/network - get wireless speed from iwconfig (LP: #1247141)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'checkbox-old/debian/changelog'
2--- checkbox-old/debian/changelog 2013-11-01 15:29:38 +0000
3+++ checkbox-old/debian/changelog 2013-11-04 17:19:03 +0000
4@@ -1,6 +1,7 @@
5 checkbox (0.16.15) UNRELEASED; urgency=low
6
7- * Incremented changelog
8+ [ Brendan Donegan ]
9+ * scripts/network - get wireless speed from iwconfig (LP: #1247141)
10
11 -- Brendan Donegan <brendan.donegan@canonical.com> Fri, 01 Nov 2013 15:29:31 +0000
12
13
14=== modified file 'checkbox-old/scripts/network'
15--- checkbox-old/scripts/network 2013-10-30 19:31:54 +0000
16+++ checkbox-old/scripts/network 2013-11-04 17:19:03 +0000
17@@ -275,8 +275,16 @@
18 def _read_data(self, type):
19 try:
20 return open(os.path.join(self.dev_path, type)).read().strip()
21+ except FileNotFoundError:
22+ print("{}: Attribute not found".format(type))
23 except OSError:
24- print("{}: Attribute not found".format(type))
25+ return None
26+
27+ def _iwconfig_max_speed(self):
28+ iwconfig = check_output(['iwconfig', self.interface],
29+ universal_newlines=True)
30+ bit_rate = re.search('(?<=Bit Rate=)[0-9]*', iwconfig)
31+ return int(bit_rate.group())
32
33 @property
34 def ipaddress(self):
35@@ -302,7 +310,11 @@
36
37 @property
38 def max_speed(self):
39- return self._read_data("speed")
40+ import pdb; pdb.set_trace()
41+ max_speed = self._read_data("speed")
42+ if not max_speed:
43+ max_speed = self._iwconfig_max_speed()
44+ return max_speed
45
46 @property
47 def macaddress(self):

Subscribers

People subscribed via source and target branches