[Sugar-devel] [PATCH sugar] Add support for XO 1.75
Simon Schampijer
simon at schampijer.de
Thu Aug 18 07:15:02 EDT 2011
The hardware specific information has been moved from '/ofw' to
'/proc/device-tree'. This has an effect on the Control Panel
where we display the serial number and the firmware number.
Furthermore the registration code needs to be aware of the possible
new place in order to send the serial number and UUID during
authentication.
Signed-off-by: Simon Schampijer <simon at laptop.org>
---
extensions/cpsection/aboutcomputer/model.py | 17 +++++++++++++++--
src/jarabe/desktop/schoolserver.py | 24 +++++++++++++++++-------
2 files changed, 32 insertions(+), 9 deletions(-)
diff --git a/extensions/cpsection/aboutcomputer/model.py b/extensions/cpsection/aboutcomputer/model.py
index 3219dd1..a02eee6 100644
--- a/extensions/cpsection/aboutcomputer/model.py
+++ b/extensions/cpsection/aboutcomputer/model.py
@@ -33,6 +33,11 @@ _NM_IFACE = 'org.freedesktop.NetworkManager'
_NM_DEVICE_IFACE = 'org.freedesktop.NetworkManager.Device'
_NM_DEVICE_TYPE_WIFI = 2
+_OFW_TREE = '/ofw'
+_PROC_TREE = '/proc/device-tree'
+_SN = 'serial-number'
+_MODEL = 'openprom/model'
+
_logger = logging.getLogger('ControlPanel - AboutComputer')
_not_available = _('Not available')
@@ -48,7 +53,11 @@ def print_aboutcomputer():
def get_serial_number():
- serial_no = _read_file('/ofw/serial-number')
+ serial_no = None
+ if os.path.exists(os.path.join(_OFW_TREE, _SN)):
+ serial_no = _read_file(os.path.join(_OFW_TREE, _SN))
+ elif os.path.exists(os.path.join(_PROC_TREE, _SN)):
+ serial_no = _read_file(os.path.join(_PROC_TREE, _SN))
if serial_no is None:
serial_no = _not_available
return serial_no
@@ -88,7 +97,11 @@ def print_build_number():
def get_firmware_number():
- firmware_no = _read_file('/ofw/openprom/model')
+ firmware_no = None
+ if os.path.exists(os.path.join(_OFW_TREE, _MODEL)):
+ firmware_no = _read_file(os.path.join(_OFW_TREE, _MODEL))
+ elif os.path.exists(os.path.join(_PROC_TREE, _MODEL)):
+ firmware_no = _read_file(os.path.join(_PROC_TREE, _MODEL))
if firmware_no is None:
firmware_no = _not_available
else:
diff --git a/src/jarabe/desktop/schoolserver.py b/src/jarabe/desktop/schoolserver.py
index 634817b..a4a401a 100644
--- a/src/jarabe/desktop/schoolserver.py
+++ b/src/jarabe/desktop/schoolserver.py
@@ -33,6 +33,10 @@ from sugar.profile import get_profile
_REGISTER_URL = 'http://schoolserver:8080/'
_REGISTER_TIMEOUT = 8
+_OFW_TREE = '/ofw'
+_PROC_TREE = '/proc/device-tree'
+_MFG_SN = 'mfg-data/SN'
+_MFG_UUID = 'mfg-data/U#'
def _generate_serial_number():
@@ -107,13 +111,16 @@ def register_laptop(url=_REGISTER_URL):
client = gconf.client_get_default()
if _have_ofw_tree():
- sn = _read_ofw('mfg-data/SN')
- uuid_ = _read_ofw('mfg-data/U#')
- sn = sn or 'SHF00000000'
- uuid_ = uuid_ or '00000000-0000-0000-0000-000000000000'
+ sn = _read_mfg_data(os.path.join(_OFW_TREE, _MFG_SN))
+ uuid_ = _read_mfg_data(os.path.join(_PROC_TREE, _MFG_UUID))
+ elif _have_proc_device_tree():
+ sn = _read_mfg_data(os.path.join(_PROC_TREE, _MFG_SN))
+ uuid_ = _read_mfg_data(os.path.join(_PROC_TREE, _MFG_UUID))
else:
sn = _generate_serial_number()
uuid_ = str(uuid.uuid1())
+ sn = sn or 'SHF00000000'
+ uuid_ = uuid_ or '00000000-0000-0000-0000-000000000000'
setting_name = '/desktop/sugar/collaboration/jabber_server'
jabber_server = client.get_string(setting_name)
@@ -150,11 +157,14 @@ def register_laptop(url=_REGISTER_URL):
def _have_ofw_tree():
- return os.path.exists('/ofw')
+ return os.path.exists(_OFW_TREE)
-def _read_ofw(path):
- path = os.path.join('/ofw', path)
+def _have_proc_device_tree():
+ return os.path.exists(_PROC_TREE)
+
+
+def _read_mfg_data(path):
if not os.path.exists(path):
return None
fh = open(path, 'r')
--
1.7.4.4
More information about the Sugar-devel
mailing list