Reviewed-by: Gonzalo Odiard <<a href="mailto:gonzalo@laptop.org">gonzalo@laptop.org</a>><br><br>Tested-by: Gonzalo Odiard <<a href="mailto:gonzalo@laptop.org">gonzalo@laptop.org</a>><br><br><div class="gmail_quote">
On Thu, Aug 18, 2011 at 8:15 AM, Simon Schampijer <span dir="ltr"><<a href="mailto:simon@schampijer.de">simon@schampijer.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
The hardware specific information has been moved from '/ofw' to<br>
'/proc/device-tree'. This has an effect on the Control Panel<br>
where we display the serial number and the firmware number.<br>
Furthermore the registration code needs to be aware of the possible<br>
new place in order to send the serial number and UUID during<br>
authentication.<br>
<br>
Signed-off-by: Simon Schampijer <<a href="mailto:simon@laptop.org">simon@laptop.org</a>><br>
---<br>
 extensions/cpsection/aboutcomputer/model.py |   17 +++++++++++++++--<br>
 src/jarabe/desktop/schoolserver.py          |   24 +++++++++++++++++-------<br>
 2 files changed, 32 insertions(+), 9 deletions(-)<br>
<br>
diff --git a/extensions/cpsection/aboutcomputer/model.py b/extensions/cpsection/aboutcomputer/model.py<br>
index 3219dd1..a02eee6 100644<br>
--- a/extensions/cpsection/aboutcomputer/model.py<br>
+++ b/extensions/cpsection/aboutcomputer/model.py<br>
@@ -33,6 +33,11 @@ _NM_IFACE = 'org.freedesktop.NetworkManager'<br>
 _NM_DEVICE_IFACE = 'org.freedesktop.NetworkManager.Device'<br>
 _NM_DEVICE_TYPE_WIFI = 2<br>
<br>
+_OFW_TREE = '/ofw'<br>
+_PROC_TREE = '/proc/device-tree'<br>
+_SN = 'serial-number'<br>
+_MODEL = 'openprom/model'<br>
+<br>
 _logger = logging.getLogger('ControlPanel - AboutComputer')<br>
 _not_available = _('Not available')<br>
<br>
@@ -48,7 +53,11 @@ def print_aboutcomputer():<br>
<br>
<br>
 def get_serial_number():<br>
-    serial_no = _read_file('/ofw/serial-number')<br>
+    serial_no = None<br>
+    if os.path.exists(os.path.join(_OFW_TREE, _SN)):<br>
+        serial_no = _read_file(os.path.join(_OFW_TREE, _SN))<br>
+    elif os.path.exists(os.path.join(_PROC_TREE, _SN)):<br>
+        serial_no = _read_file(os.path.join(_PROC_TREE, _SN))<br>
     if serial_no is None:<br>
         serial_no = _not_available<br>
     return serial_no<br>
@@ -88,7 +97,11 @@ def print_build_number():<br>
<br>
<br>
 def get_firmware_number():<br>
-    firmware_no = _read_file('/ofw/openprom/model')<br>
+    firmware_no = None<br>
+    if os.path.exists(os.path.join(_OFW_TREE, _MODEL)):<br>
+        firmware_no = _read_file(os.path.join(_OFW_TREE, _MODEL))<br>
+    elif os.path.exists(os.path.join(_PROC_TREE, _MODEL)):<br>
+        firmware_no = _read_file(os.path.join(_PROC_TREE, _MODEL))<br>
     if firmware_no is None:<br>
         firmware_no = _not_available<br>
     else:<br>
diff --git a/src/jarabe/desktop/schoolserver.py b/src/jarabe/desktop/schoolserver.py<br>
index 634817b..a4a401a 100644<br>
--- a/src/jarabe/desktop/schoolserver.py<br>
+++ b/src/jarabe/desktop/schoolserver.py<br>
@@ -33,6 +33,10 @@ from sugar.profile import get_profile<br>
<br>
 _REGISTER_URL = '<a href="http://schoolserver:8080/" target="_blank">http://schoolserver:8080/</a>'<br>
 _REGISTER_TIMEOUT = 8<br>
+_OFW_TREE = '/ofw'<br>
+_PROC_TREE = '/proc/device-tree'<br>
+_MFG_SN = 'mfg-data/SN'<br>
+_MFG_UUID = 'mfg-data/U#'<br>
<br>
<br>
 def _generate_serial_number():<br>
@@ -107,13 +111,16 @@ def register_laptop(url=_REGISTER_URL):<br>
     client = gconf.client_get_default()<br>
<br>
     if _have_ofw_tree():<br>
-        sn = _read_ofw('mfg-data/SN')<br>
-        uuid_ = _read_ofw('mfg-data/U#')<br>
-        sn = sn or 'SHF00000000'<br>
-        uuid_ = uuid_ or '00000000-0000-0000-0000-000000000000'<br>
+        sn = _read_mfg_data(os.path.join(_OFW_TREE, _MFG_SN))<br>
+        uuid_ = _read_mfg_data(os.path.join(_PROC_TREE, _MFG_UUID))<br>
+    elif _have_proc_device_tree():<br>
+        sn = _read_mfg_data(os.path.join(_PROC_TREE, _MFG_SN))<br>
+        uuid_ = _read_mfg_data(os.path.join(_PROC_TREE, _MFG_UUID))<br>
     else:<br>
         sn = _generate_serial_number()<br>
         uuid_ = str(uuid.uuid1())<br>
+    sn = sn or 'SHF00000000'<br>
+    uuid_ = uuid_ or '00000000-0000-0000-0000-000000000000'<br>
<br>
     setting_name = '/desktop/sugar/collaboration/jabber_server'<br>
     jabber_server = client.get_string(setting_name)<br>
@@ -150,11 +157,14 @@ def register_laptop(url=_REGISTER_URL):<br>
<br>
<br>
 def _have_ofw_tree():<br>
-    return os.path.exists('/ofw')<br>
+    return os.path.exists(_OFW_TREE)<br>
<br>
<br>
-def _read_ofw(path):<br>
-    path = os.path.join('/ofw', path)<br>
+def _have_proc_device_tree():<br>
+    return os.path.exists(_PROC_TREE)<br>
+<br>
+<br>
+def _read_mfg_data(path):<br>
     if not os.path.exists(path):<br>
         return None<br>
     fh = open(path, 'r')<br>
<font color="#888888">--<br>
1.7.4.4<br>
<br>
_______________________________________________<br>
Sugar-devel mailing list<br>
<a href="mailto:Sugar-devel@lists.sugarlabs.org">Sugar-devel@lists.sugarlabs.org</a><br>
<a href="http://lists.sugarlabs.org/listinfo/sugar-devel" target="_blank">http://lists.sugarlabs.org/listinfo/sugar-devel</a><br>
</font></blockquote></div><br>