From 9c5d5cf7d6bebcfb0dd0ffbaa0a10da69520a056 Mon Sep 17 00:00:00 2001
From: Gonzalo Odiard <godiard@gmail.com>
Date: Fri, 21 Dec 2012 17:46:45 -0300
Subject: [PATCH] Identify xo model in 13.1.0 images
In new images /sys/class/dmi/id/ does not exist anymore.
To identify the hardware we have /bin/olpc-hwinfo.
Signed-off-by: Gonzalo Odiard <gonzalo@laptop.org>
---
hw.py | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)
diff --git a/hw.py b/hw.py
index d678e37..119301b 100644
a
|
b
|
|
16 | 16 | # Boston, MA 02111-1307, USA. |
17 | 17 | |
18 | 18 | import os |
| 19 | import subprocess |
| 20 | |
19 | 21 | |
20 | 22 | def _get_dmi(node): |
21 | 23 | path = os.path.join('/sys/class/dmi/id', node) |
… |
… |
def _get_dmi(node): |
24 | 26 | except: |
25 | 27 | return None |
26 | 28 | |
| 29 | |
27 | 30 | def get_xo_version(): |
28 | | if _get_dmi('product_name') != 'XO': |
29 | | return 0 |
30 | 31 | version = _get_dmi('product_version') |
| 32 | if version is None: |
| 33 | hwinfo_path = '/bin/olpc-hwinfo' |
| 34 | if os.path.exists(hwinfo_path) and os.access(hwinfo_path, os.X_OK): |
| 35 | model = subprocess.check_output([hwinfo_path, 'model']) |
| 36 | version = model.strip() |
| 37 | |
31 | 38 | if version == '1': |
32 | 39 | return 1 |
33 | 40 | if version == '1.5': |
34 | 41 | return 1.5 |
| 42 | if version == '1.75': |
| 43 | return 1.75 |
| 44 | if version == '4': |
| 45 | return 4 |
35 | 46 | else: |
36 | 47 | return 0 |
37 | | |