[Sugar-devel] [PATCH sugar] Control Panel "About my Computer": show information on XO 1.75 OLPC #11232

Walter Bender walter.bender at gmail.com
Wed Sep 28 12:24:57 EDT 2011


On Wed, Sep 28, 2011 at 10:24 AM, Simon Schampijer <simon at schampijer.de> wrote:
> '/ofw' has been removed on the XOs now. We need to refine the
> check if the machine is an XO in order to display the
> information accordingly.

Can we finally agree to create a toolkit method for this? As an
activity maintainer who needs to occasionally do things differently on
an XO than other HW, it would be really nice to not have to keep
changing my XO detection methods as the system changes under me.

regards.

-walter

>
> Follow up patch of b454c1253d95fc62c0cdf9ce34c40397a3c6f49e
>
> Signed-off-by: Simon Schampijer <simon at laptop.org>
> ---
>  extensions/cpsection/aboutcomputer/model.py |   46 +++++++++++++++++++++++++++
>  extensions/cpsection/aboutcomputer/view.py  |    4 +-
>  2 files changed, 48 insertions(+), 2 deletions(-)
>
> diff --git a/extensions/cpsection/aboutcomputer/model.py b/extensions/cpsection/aboutcomputer/model.py
> index a02eee6..8cf3abb 100644
> --- a/extensions/cpsection/aboutcomputer/model.py
> +++ b/extensions/cpsection/aboutcomputer/model.py
> @@ -41,6 +41,52 @@ _MODEL = 'openprom/model'
>  _logger = logging.getLogger('ControlPanel - AboutComputer')
>  _not_available = _('Not available')
>
> +XO_1 = '1'
> +XO_1_5 = '1.5'
> +XO_1_75 = '1.75'
> +
> +
> +def _get_xo_version():
> +    """Gets the version of the XO
> +
> +    There has been three revisions of the XO hardware as
> +    of today: 1, 1.5, 1.75
> +
> +    Returns: a string indicating the version of the XO or None if
> +             the hardware is not an XO
> +
> +    """
> +    xo_version = None
> +    if os.path.exists('/proc/device-tree/banner-name'):
> +        content = _read_file('/proc/device-tree/banner-name')
> +        if re.match(r'OLPC\ [BC][0-9]', content):
> +            xo_version = XO_1
> +        elif re.match(r'OLPC\ D[0-9]', content):
> +            xo_version = XO_1_5
> +        elif re.match(r'OLPC\ 1[ABC][0-9]', content):
> +            xo_version = XO_1_75
> +    elif os.path.exists('/sys/class/dmi/id/product_name'):
> +        if _read_file('/sys/class/dmi/id/product_name') == 'XO' and \
> +                os.path.exists('/sys/class/dmi/id/product_version'):
> +            content = _read_file('/sys/class/dmi/id/product_version')
> +            if content == '1':
> +                xo_version = XO_1
> +            elif content == '1.5':
> +                xo_version = XO_1_5
> +    elif os.path.exists('/ofw/banner-name'):
> +        content = _read_file('/ofw/banner-name')
> +        if re.match(r'OLPC\ [BC][0-9]', content):
> +            xo_version = XO_1
> +    return xo_version
> +
> +
> +def is_xo():
> +    """Checks if the underlying hardware is an XO
> +
> +    Returns: True in the case the underlying hardware is an XO
> +    """
> +    return _get_xo_version() is not None
> +
>
>  def get_aboutcomputer():
>     msg = 'Serial Number: %s \nBuild Number: %s \nFirmware Number: %s \n' \
> diff --git a/extensions/cpsection/aboutcomputer/view.py b/extensions/cpsection/aboutcomputer/view.py
> index e5f2f32..baddbe2 100644
> --- a/extensions/cpsection/aboutcomputer/view.py
> +++ b/extensions/cpsection/aboutcomputer/view.py
> @@ -47,7 +47,7 @@ class AboutComputer(SectionView):
>         scrollwindow.add_with_viewport(self._vbox)
>         self._vbox.show()
>
> -        if os.path.exists('/ofw'):
> +        if self._model.is_xo():
>             self._setup_identity()
>
>         self._setup_software()
> @@ -127,7 +127,7 @@ class AboutComputer(SectionView):
>         box_software.pack_start(box_sugar, expand=False)
>         box_sugar.show()
>
> -        if os.path.exists('/ofw'):
> +        if self._model.is_xo():
>             box_firmware = gtk.HBox(spacing=style.DEFAULT_SPACING)
>             label_firmware = gtk.Label(_('Firmware:'))
>             label_firmware.set_alignment(1, 0)
> --
> 1.7.4.4
>
> _______________________________________________
> Sugar-devel mailing list
> Sugar-devel at lists.sugarlabs.org
> http://lists.sugarlabs.org/listinfo/sugar-devel
>



-- 
Walter Bender
Sugar Labs
http://www.sugarlabs.org


More information about the Sugar-devel mailing list