diff options
author | Vincent Vinet <vince.vinet@gmail.com> | 2009-10-19 20:15:41 (GMT) |
---|---|---|
committer | Vincent Vinet <vince.vinet@gmail.com> | 2009-10-19 20:15:41 (GMT) |
commit | 912528253fcf1fc43c1a2d02ffe6e540fe60d8e7 (patch) | |
tree | 1d5c075046d260580c9eeb27d0d7d09045a7d4b5 /tutorius/engine.py | |
parent | 6584510d390a37153c20974da6704a907058fea0 (diff) |
Merge the TProbe Integration and fix merging induced bugs
Diffstat (limited to 'tutorius/engine.py')
-rw-r--r-- | tutorius/engine.py | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/tutorius/engine.py b/tutorius/engine.py new file mode 100644 index 0000000..dda9f3f --- /dev/null +++ b/tutorius/engine.py @@ -0,0 +1,48 @@ +import logging +import dbus.mainloop.glib +from jarabe.model import shell + +from sugar.tutorius.bundler import TutorialStore +from sugar.bundle.activitybundle import ActivityBundle + +class Engine: + """ + Driver for the execution of tutorials + """ + + def __init__(self): + # FIXME Probe management should be in the probe manager + dbus.mainloop.glib.DBusGMainLoop(set_as_default=True) + #FIXME shell.get_model() will only be useful in the shell process + self._shell = shell.get_model() + self._tutorial = None + + def launch(self, tutorialID): + """ Launch a tutorial + @param tutorialID unique tutorial identifier used to retrieve it from the disk + """ + if self._tutorial: + self._tutorial.detach() + self._tutorial = None + + store = TutorialStore() + + #Get the active activity from the shell + activity = self._shell.get_active_activity() + self._tutorial = store.load_tutorial(tutorialID, bundle_path=activity.get_bundle_path()) + + #TProbes automatically use the bundle id, available from the ActivityBundle + bundle = ActivityBundle(activity.get_bundle_path()) + self._tutorial.attach(bundle.get_bundle_id()) + + def stop(self): + """ Stop the current tutorial + """ + self._tutorial.detach() + self._tutorial = None + + def pause(self): + """ Interrupt the current tutorial and save its state in the journal + """ + raise NotImplementedError("Unable to store tutorial state") + |