[Sugar-devel] ObjectChooser() Issue?

Walter Bender walter.bender at gmail.com
Sat Nov 20 16:47:02 EST 2010


On Sat, Nov 20, 2010 at 4:37 PM, Art Hunkins <abhunkin at uncg.edu> wrote:
> One more question:
>
> This code tests for the presence of an XO-1 (thanks originally to Walter):
>
>  if os.path.exists("/sys/power/olpc-pm"):
>
> Normally this is also a test for Sugar 0.82. I want, however, also to test
> for Sugar *upgrades* on the XO-1; I don't want the same result as for 0.82
> (as, for example, if 0.84 is installed).
>
> So, do I use the same test, or do I need some other (if so, what)?
>
> (Another way of phrasing the question: is the above essentially a hardware
> or a software test?)
>
> Art Hunkins
>
> ----- Original Message ----- From: "Sascha Silbe"
> <sascha-ml-reply-to-2010-3 at silbe.org>
> To: "sugar-devel" <sugar-devel at lists.sugarlabs.org>
> Sent: Saturday, November 20, 2010 3:38 AM
> Subject: Re: [Sugar-devel] ObjectChooser() Issue?
>
>
>> _______________________________________________
>> Sugar-devel mailing list
>> Sugar-devel at lists.sugarlabs.org
>> http://lists.sugarlabs.org/listinfo/sugar-devel
>>
>
> _______________________________________________
> Sugar-devel mailing list
> Sugar-devel at lists.sugarlabs.org
> http://lists.sugarlabs.org/listinfo/sugar-devel
>

Here is what I am using these days for my HARDWARE tests:
XO1 = 'xo1'
XO15 = 'xo1.5'
UNKNOWN = 'unknown'

def get_hardware():
    """ Determine whether we are using XO 1.0, 1.5, or "unknown" hardware """
    bus = dbus.SystemBus()

    comp_obj = bus.get_object('org.freedesktop.Hal',
                              '/org/freedesktop/Hal/devices/computer')
    dev = dbus.Interface(comp_obj, 'org.freedesktop.Hal.Device')
    if dev.PropertyExists('system.hardware.vendor') and \
            dev.PropertyExists('system.hardware.version'):
        if dev.GetProperty('system.hardware.vendor') == 'OLPC':
            if dev.GetProperty('system.hardware.version') == '1.5':
                return XO15
            else:
                return XO1
        else:
            return UNKNOWN
    elif os.path.exists('/etc/olpc-release') or \
         os.path.exists('/sys/power/olpc-pm'):
        return XO1
    else:
        return UNKNOWN


Regarding SOFTWARE, I usually determine this at import time:

try:
    from sugar.graphics.toolbarbox import ToolbarBox
    _have_toolbox = True
except ImportError:
    _have_toolbox = False

Only 0.86+ have ToolbarBox
-walter

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


More information about the Sugar-devel mailing list