Ticket #4351: 0001-Identify-xo-model-in-13.1.0-images.patch

File 0001-Identify-xo-model-in-13.1.0-images.patch, 1.3 KB (added by godiard, 10 years ago)
  • hw.py

    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  
    1616# Boston, MA 02111-1307, USA.
    1717
    1818import os
     19import subprocess
     20
    1921
    2022def _get_dmi(node):
    2123    path = os.path.join('/sys/class/dmi/id', node)
    def _get_dmi(node): 
    2426    except:
    2527        return None
    2628
     29
    2730def get_xo_version():
    28     if _get_dmi('product_name') != 'XO':
    29         return 0
    3031    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
    3138    if version == '1':
    3239        return 1
    3340    if version == '1.5':
    3441        return 1.5
     42    if version == '1.75':
     43        return 1.75
     44    if version == '4':
     45        return 4
    3546    else:
    3647        return 0
    37