Changes

Jump to navigation Jump to search
631 bytes added ,  11:11, 9 April 2011
Line 78: Line 78:  
if os.path.exists('/etc/olpc-release'):
 
if os.path.exists('/etc/olpc-release'):
 
     ...
 
     ...
 +
</pre></li>
 +
</ol>
 +
 +
:Or, check the in /sys/class/dmi/id for the 'product_name' and 'product_version':
 +
<ol style="list-style-type:none">
 +
<li>
 +
<pre>
 +
def get_hardware():
 +
    """ Determine whether we are using XO 1.0, 1.5, or "unknown" hardware """
 +
    if _get_dmi('product_name') != 'XO':
 +
        return UNKNOWN
 +
    version = _get_dmi('product_version')
 +
    if version == '1':
 +
        return XO1
 +
    elif version == '1.5':
 +
        return XO15
 +
    else:
 +
        return UNKNOWN
 +
 +
 +
def _get_dmi(node):
 +
    path = os.path.join('/sys/class/dmi/id', node)
 +
    try:
 +
        return open(path).readline().strip()
 +
    except:
 +
        return None
 
</pre></li>
 
</pre></li>
 
</ol>
 
</ol>

Navigation menu