<div dir="ltr">Thanks James.<div>Released a new version with your changes.</div><div>I moved the activity to github too (<a href="https://github.com/godiard/log-activity">https://github.com/godiard/log-activity</a>)</div><div><br></div><div>Gonzalo</div><div><br></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Sep 21, 2014 at 10:35 PM, James Cameron <span dir="ltr"><<a href="mailto:quozl@laptop.org" target="_blank">quozl@laptop.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Log collections showed wrong firmware version. Cause was use of the BV<br>
tag instead of openprom/model. The BV tag is the base version of<br>
firmware used in manufacturing. openprom/model is the current version<br>
of firmware.<br>
<br>
Also separated null trimming into a separate method.<br>
---<br>
logcollect.py | 36 +++++++++++++++++++++++++++++-------<br>
1 file changed, 29 insertions(+), 7 deletions(-)<br>
<br>
diff --git a/logcollect.py b/logcollect.py<br>
index 5d6e683..10c57b1 100644<br>
--- a/logcollect.py<br>
+++ b/logcollect.py<br>
@@ -113,6 +113,11 @@ class MachineProperties:<br>
if line.find('MemFree:') > -1:<br>
return line[8:].strip()<br>
<br>
+ def _trim_null(self, v):<br>
+ if v != '' and ord(v[len(v)-1]) == 0:<br>
+ v = v[:len(v)-1]<br>
+ return v<br>
+<br>
def _mfg_data(self, item):<br>
"""Return mfg data item from mfg-data directory"""<br>
<br>
@@ -124,13 +129,9 @@ class MachineProperties:<br>
if mfg_path == None:<br>
return ''<br>
<br>
- v = self.__read_file(mfg_path)<br>
- # Remove trailing 0 character, if any:<br>
- if v != '' and ord(v[len(v)-1]) == 0:<br>
- v = v[:len(v)-1]<br>
-<br>
+ v = self._trim_null(self.__read_file(mfg_path))<br>
return v<br>
-<br>
+<br>
def laptop_serial_number(self):<br>
return self._mfg_data('SN')<br>
<br>
@@ -158,7 +159,28 @@ class MachineProperties:<br>
return self._mfg_data('WM')<br>
<br>
def laptop_bios_version(self):<br>
- return self._mfg_data('BV')<br>
+ try:<br>
+ d = open('/proc/device-tree/openprom/model', 'r').read()<br>
+ v = self._trim_null(d)<br>
+ return v<br>
+ except:<br>
+ pass<br>
+<br>
+ try:<br>
+ d = open('/ofw/openprom/model', 'r').read()<br>
+ v = self._trim_null(d)<br>
+ return v<br>
+ except:<br>
+ pass<br>
+<br>
+ try:<br>
+ d = open('/sys/class/dmi/id/bios_version', 'r').read()<br>
+ v = self._trim_null(d)<br>
+ return v<br>
+ except:<br>
+ pass<br>
+<br>
+ return ''<br>
<br>
def laptop_country(self):<br>
return self._mfg_data('LA')<br>
<span class="HOEnZb"><font color="#888888">--<br>
1.8.3.2<br>
<br>
</font></span></blockquote></div><br><br clear="all"><div><br></div>-- <br><div dir="ltr">Gonzalo Odiard<br><br><div>SugarLabs - Software for children learning <br></div></div>
</div>