[Sugar-devel] [PATCH sugar] about my computer, check wlan0 before eth0

James Cameron quozl at laptop.org
Wed Nov 24 18:14:34 EST 2010


On recent Fedora distributions, wireless ethernet devices appear as
wlan0 instead of eth0.  This causes "About my Computer" to not show
wireless firmware version.  Affects XO-1 and XO-1.5 with Fedora 14.

Patch tested on XO-1.5 with Fedora 11.
http://dev.laptop.org/ticket/10478
---
 extensions/cpsection/aboutcomputer/model.py |   23 ++++++++++++-----------
 1 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/extensions/cpsection/aboutcomputer/model.py b/extensions/cpsection/aboutcomputer/model.py
index e3b9687..f7ee6dc 100644
--- a/extensions/cpsection/aboutcomputer/model.py
+++ b/extensions/cpsection/aboutcomputer/model.py
@@ -95,17 +95,18 @@ def print_firmware_number():
 
 
 def get_wireless_firmware():
-    try:
-        info = subprocess.Popen(['/usr/sbin/ethtool', '-i', 'eth0'],
-                                stdout=subprocess.PIPE).stdout.readlines()
-    except OSError:
-        return _not_available
-    try:
-        wireless_firmware = [line for line in info
-                             if line.startswith('firmware')][0].split()[1]
-    except IndexError:
-        wireless_firmware = _not_available
-    return wireless_firmware
+    for netdev in ['wlan0', 'eth0']:
+        try:
+            info = subprocess.Popen(['/usr/sbin/ethtool', '-i', netdev],
+                                    stdout=subprocess.PIPE).stdout.readlines()
+        except OSError:
+            continue
+        try:
+            return [line for line in info
+                    if line.startswith('firmware')][0].split()[1]
+        except IndexError:
+            continue
+    return _not_available
 
 
 def print_wireless_firmware():
-- 
1.7.2.3

-- 
James Cameron
http://quozl.linux.org.au/


More information about the Sugar-devel mailing list