[Pkg-sugar-commit] [sugar-record-activity] 04/09: Extend hardware detection

Jonas Smedegaard dr at jones.dk
Mon Sep 14 19:38:33 UTC 2015


This is an automated email from the git hooks/post-receive script.

js pushed a commit to branch master
in repository sugar-record-activity.

commit d1b6aefb86b6494d6b019e98909ff48c2199a584
Author: James Cameron <quozl at laptop.org>
Date:   Thu Aug 27 13:08:55 2015 +1000

    Extend hardware detection
    
    - add XO-1.75 and XO-4,
    
    - add call to olpc-hwinfo for systems without DMI support,
    
    - add unit test harness.
---
 hw.py | 29 ++++++++++++++++++++++++-----
 1 file changed, 24 insertions(+), 5 deletions(-)

diff --git a/hw.py b/hw.py
index d678e37..16aedac 100644
--- a/hw.py
+++ b/hw.py
@@ -16,6 +16,7 @@
 # Boston, MA 02111-1307, USA.
 
 import os
+import subprocess
 
 def _get_dmi(node):
     path = os.path.join('/sys/class/dmi/id', node)
@@ -24,14 +25,32 @@ def _get_dmi(node):
     except:
         return None
 
+def _get_model():
+    null = open(os.devnull, 'w')
+    args = 'olpc-hwinfo model'.split(' ')
+    try:
+        model = subprocess.check_output(args, stderr=null).strip()
+    except:
+        model = None
+    null.close()
+    return model
+
 def get_xo_version():
-    if _get_dmi('product_name') != 'XO':
-        return 0
-    version = _get_dmi('product_version')
+    version = None
+    if _get_dmi('product_name') == 'XO':
+        version = _get_dmi('product_version')
+    if version is None:
+        version = _get_model()
     if version == '1':
         return 1
-    if version == '1.5':
-        return 1.5
+    elif version == '1.5':
+         return 1.5
+    elif version == '1.75':
+        return 1.75
+    elif version == '4':
+        return 4
     else:
         return 0
 
+if __name__ == "__main__":
+    print get_xo_version()

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-sugar/sugar-record-activity.git



More information about the pkg-sugar-commit mailing list