sugarbot's aim is to provide testing and automation facilities for the OLPC Project's Sugar GUI. The project must first identify and evaluate possible implementation options, and then implement the best choice. Although it has a Sugar focus, sugarbot should be easily extensible to other Python-based GUI's.

Saturday, July 12, 2008

Automated Launching: Go!

Using just about the most obscure Python code I have ever written, I have just made sugarbot fully automatable.

It requires a small patch to in the main Sugar directory (/usr/share/sugar/shell/, and adding a file to the same directory. It launches sugarbot by simulating a click on the sugarbot icon in the frame.

Will put the code up on SVN later, it's Pizza time now!

Important Code:
# =========================================================
# The magnitude of this hack compares favorably with the
# current national debt.
boxChildren =
tray = [k for k in boxChildren if isinstance(k,ActivitiesTray)]
if tray:
children = tray[0]._tray.get_children()
activities = [k for k in children if isinstance(k, ActivityButton)]
sbList = [k for k in activities if"sugarbot"]
# ========================================================

if len(sbList) > 0: sbList[0].emit('clicked') patch:
model = ShellModel()
shell = Shell(model)
service = ShellService(shell)

if os.environ.has_key("SUGARBOT_EMULATOR"):
from sugarbotlauncher import SugarbotLauncher
sbLauncher = SugarbotLauncher(model,shell,service)

except KeyboardInterrupt:
print 'Ctrl+C pressed, exiting...'

No comments: