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>2012-07-25 17:06:36 (GMT)
committer Walter Bender <walter.bender@gmail.com>2012-07-25 17:06:36 (GMT)
commit74fe18db0e83b91915e2ebebc29a9dc95f166282 (patch)
tree282fbc930f66fe2370321fd2e17720f6fd1c3684 /utils.py
parent07ff4d28aded6bcb190527518787fec3335e9f28 (diff)
toggle history button icon
Diffstat (limited to 'utils.py')
-rw-r--r--utils.py40
1 files changed, 39 insertions, 1 deletions
diff --git a/utils.py b/utils.py
index ffab831..796b041 100644
--- a/utils.py
+++ b/utils.py
@@ -9,7 +9,7 @@
# along with this library; if not, write to the Free Software
# Foundation, 51 Franklin Street, Suite 500 Boston, MA 02110-1335 USA
-
+import os
from StringIO import StringIO
try:
OLD_SUGAR_SYSTEM = False
@@ -26,6 +26,44 @@ except (ImportError, AttributeError):
OLD_SUGAR_SYSTEM = True
+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 json_load(text):
""" Load JSON data using what ever resources are available. """
if OLD_SUGAR_SYSTEM is True: