[Sugar-devel] [PATCH 1/3] logcollect: collect firmware version not BV

Gonzalo Odiard godiard at sugarlabs.org
Wed Sep 24 08:53:51 EDT 2014


Thanks James.
Released a new version with your changes.
I moved the activity to github too (https://github.com/godiard/log-activity)

Gonzalo



On Sun, Sep 21, 2014 at 10:35 PM, James Cameron <quozl at laptop.org> wrote:

> Log collections showed wrong firmware version.  Cause was use of the BV
> tag instead of openprom/model.  The BV tag is the base version of
> firmware used in manufacturing.  openprom/model is the current version
> of firmware.
>
> Also separated null trimming into a separate method.
> ---
>  logcollect.py | 36 +++++++++++++++++++++++++++++-------
>  1 file changed, 29 insertions(+), 7 deletions(-)
>
> diff --git a/logcollect.py b/logcollect.py
> index 5d6e683..10c57b1 100644
> --- a/logcollect.py
> +++ b/logcollect.py
> @@ -113,6 +113,11 @@ class MachineProperties:
>              if line.find('MemFree:') > -1:
>                  return line[8:].strip()
>
> +    def _trim_null(self, v):
> +        if v != '' and ord(v[len(v)-1]) == 0:
> +            v = v[:len(v)-1]
> +        return v
> +
>      def _mfg_data(self, item):
>          """Return mfg data item from mfg-data directory"""
>
> @@ -124,13 +129,9 @@ class MachineProperties:
>          if mfg_path == None:
>              return ''
>
> -        v = self.__read_file(mfg_path)
> -        # Remove trailing 0 character, if any:
> -        if v != '' and ord(v[len(v)-1]) == 0:
> -            v = v[:len(v)-1]
> -
> +        v = self._trim_null(self.__read_file(mfg_path))
>          return v
> -
> +
>      def laptop_serial_number(self):
>          return self._mfg_data('SN')
>
> @@ -158,7 +159,28 @@ class MachineProperties:
>          return self._mfg_data('WM')
>
>      def laptop_bios_version(self):
> -        return self._mfg_data('BV')
> +        try:
> +            d = open('/proc/device-tree/openprom/model', 'r').read()
> +            v = self._trim_null(d)
> +            return v
> +        except:
> +            pass
> +
> +        try:
> +            d = open('/ofw/openprom/model', 'r').read()
> +            v = self._trim_null(d)
> +            return v
> +        except:
> +            pass
> +
> +        try:
> +            d = open('/sys/class/dmi/id/bios_version', 'r').read()
> +            v = self._trim_null(d)
> +            return v
> +        except:
> +            pass
> +
> +        return ''
>
>      def laptop_country(self):
>          return self._mfg_data('LA')
> --
> 1.8.3.2
>
>


-- 
Gonzalo Odiard

SugarLabs - Software for children learning
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sugarlabs.org/archive/sugar-devel/attachments/20140924/4c504d37/attachment.html>


More information about the Sugar-devel mailing list