Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/utils.py
diff options
context:
space:
mode:
authorWalter Bender <walter.bender@gmail.com>2011-08-18 14:40:51 (GMT)
committer Walter Bender <walter.bender@gmail.com>2011-08-18 14:40:51 (GMT)
commit2d59828620b5e0803305c6deece6c8cf1115f184 (patch)
tree3e68fd800fe1bc6b17fa73410f4cba0b0338bf51 /utils.py
parent30da23fd6c819253348347f91f0275d4907ecd3a (diff)
fix bug in XO 1.75 detection
Diffstat (limited to 'utils.py')
-rw-r--r--utils.py58
1 files changed, 37 insertions, 21 deletions
diff --git a/utils.py b/utils.py
index 1914aa8..c826c3c 100644
--- a/utils.py
+++ b/utils.py
@@ -21,6 +21,43 @@ from sugar.graphics.toolbutton import ToolButton
from sugar.graphics.combobox import ComboBox
from sugar.graphics.toolcombobox import ToolComboBox
+XO1 = 'xo1'
+XO15 = 'xo1.5'
+XO175 = 'xo1.75'
+UNKNOWN = 'unknown'
+
+
+def get_hardware():
+ """ Determine whether we are using XO 1.0, 1.5, or "unknown" hardware """
+ product = _get_dmi('product_name')
+ if product is None:
+ if os.path.exists('/sys/devices/platform/lis3lv02d/position'):
+ return XO175 # FIXME: temporary check for XO 1.75
+ elif os.path.exists('/etc/olpc-release') or \
+ os.path.exists('/sys/power/olpc-pm'):
+ return XO1
+ else:
+ return UNKNOWN
+ if product != 'XO':
+ return UNKNOWN
+ version = _get_dmi('product_version')
+ if version == '1':
+ return XO1
+ elif version == '1.5':
+ return XO15
+ else:
+ return XO175
+
+
+def _get_dmi(node):
+ ''' The desktop management interface should be a reliable source
+ for product and version information. '''
+ path = os.path.join('/sys/class/dmi/id', node)
+ try:
+ return open(path).readline().strip()
+ except:
+ return None
+
def get_path(activity, subpath):
""" Find a Rainbow-approved place for temporary files. """
@@ -172,27 +209,6 @@ def genblank(w, h, colors, stroke_width=1.0):
return svg_string
-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
-
-
class SVG:
''' SVG generators '''