Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tests/enginetests.py4
-rw-r--r--tutorius/TProbe.py2
-rw-r--r--tutorius/engine.py48
-rw-r--r--tutorius/translator.py4
4 files changed, 21 insertions, 37 deletions
diff --git a/tests/enginetests.py b/tests/enginetests.py
index 4a8a3ca..2d1e723 100644
--- a/tests/enginetests.py
+++ b/tests/enginetests.py
@@ -103,7 +103,7 @@ class MockProbeMgrMultiAddons(object):
currentActivity = property(fget=lambda s:s, fset=lambda s, v: v)
def run_install_cb(self, action_number, action):
- self._action_installed_cb_list[action_number](action, str(uuid1()))
+ self._action_installed_cb_list[action_number](str(uuid1()))
def run_install_error_cb(self, action_number):
self._install_error_cb_list[action_number](Exception("Could not install action..."))
@@ -155,7 +155,7 @@ class MockProbeMgr(object):
def install(self, action, action_installed_cb, error_cb):
self.action = action
- self._action_installed_cb = partial(action_installed_cb, action)
+ self._action_installed_cb = action_installed_cb
self._install_error_cb = partial(error_cb, action)
def update(self, action_address, newaction):
diff --git a/tutorius/TProbe.py b/tutorius/TProbe.py
index 02352af..e408fe9 100644
--- a/tutorius/TProbe.py
+++ b/tutorius/TProbe.py
@@ -93,8 +93,6 @@ class TProbe(dbus.service.Object):
LOGGER.debug("TProbe :: registering '%s' with unique_id '%s'", self._activity_name, activity.get_id())
self._service_proxy.register_probe(self._activity_name, self._unique_id)
-
-
def start(self):
"""
diff --git a/tutorius/engine.py b/tutorius/engine.py
index 34616f6..46e1152 100644
--- a/tutorius/engine.py
+++ b/tutorius/engine.py
@@ -31,12 +31,12 @@ STOP_MSG_PRIORITY = 5
EVENT_NOTIFICATION_MSG_PRIORITY = 10
# List of runner states
-RUNNER_STATE_IDLE = 0
-RUNNER_STATE_SETUP_ACTIONS = 1
-RUNNER_STATE_SETUP_EVENTS = 2
-RUNNER_STATE_AWAITING_NOTIFICATIONS = 3
-RUNNER_STATE_UNINSTALLING_ACTIONS = 4
-RUNNER_STATE_UNSUBSCRIBING_EVENTS = 5
+RUNNER_STATE_IDLE = "idle"
+RUNNER_STATE_SETUP_ACTIONS = "setup_actions"
+RUNNER_STATE_SETUP_EVENTS = "setup_events"
+RUNNER_STATE_AWAITING_NOTIFICATIONS = "awaiting_notification"
+RUNNER_STATE_UNINSTALLING_ACTIONS = "uninstalling_actions"
+RUNNER_STATE_UNSUBSCRIBING_EVENTS = "unsubscribing_events"
LOGGER = logging.getLogger("sugar.tutorius.engine")
@@ -67,7 +67,6 @@ class TutorialRunner(object):
self._state = None
#Cached objects
- self._actions = {}
self._installed_actions = {}
self._installation_errors = {}
@@ -93,9 +92,9 @@ class TutorialRunner(object):
self._runner_state == RUNNER_STATE_SETUP_EVENTS:
heappush(self._message_queue, (STOP_MSG_PRIORITY, None))
else:
- self._execute_stop()
+ self._execute_stop()
- def action_installed(self, action_name, action, address):
+ def action_installed(self, action_name, address):
LOGGER.debug("TutorialRunner :: Action %s received address %s"%(action_name, address))
self._installed_actions[action_name] = address
# Verify if we just completed the installation of the actions for this state
@@ -151,20 +150,11 @@ class TutorialRunner(object):
self._runner_state = RUNNER_STATE_AWAITING_NOTIFICATIONS
self._process_pending_messages()
- def _uninstall_actions(self):
- self._runner_state = RUNNER_STATE_UNINSTALLING_ACTIONS
- self._remove_installed_actions()
- self._execute_stop()
-
- def _unsubscribe_events(self):
- self._runner_state = RUNNER_STATE_UNSUBSCRIBING_EVENTS
- self._remove_subscribed_events()
- self._uninstall_actions()
-
###########################################################################
# Helper functions
def _execute_stop(self):
self.setCurrentActivity() #Temp Hack until activity in events/actions
+ self._teardownState()
self._state = None
self._runner_state = RUNNER_STATE_IDLE
@@ -176,6 +166,7 @@ class TutorialRunner(object):
for (this_event, this_next_state_name) in transitions.values():
if event == this_event and next_state == this_next_state_name:
self.enterState(next_state)
+ break
elif self._runner_state == RUNNER_STATE_SETUP_EVENTS:
LOGGER.debug("TutorialRunner :: Queuing event notification to go to state %s"%next_state)
# Push the message on the queue
@@ -194,7 +185,6 @@ class TutorialRunner(object):
for (action_name, action_address) in self._installed_actions.items():
LOGGER.debug("TutorialRunner :: Uninstalling action %s with address %s"%(action_name, action_address))
self._pM.uninstall(action_address)
- self._actions = {}
self._installed_actions.clear()
self._installation_errors.clear()
@@ -206,10 +196,12 @@ class TutorialRunner(object):
self._subscription_errors.clear()
def _verify_action_install_state(self):
+ actions = self._tutorial.get_action_dict(self._state)
+
# Do the check to see if we have finished installing all the actions by either having
# received a address for it or an error message
install_complete = True
- for (this_action_name, this_action) in self._actions.items():
+ for (this_action_name, this_action) in actions.items():
if not this_action_name in self._installed_actions.keys() and \
not this_action_name in self._installation_errors.keys():
# There's at least one uninstalled action, so we still wait
@@ -244,13 +236,7 @@ class TutorialRunner(object):
LOGGER.debug("TutorialRunner :: Stop message taken from message queue")
# We can safely ignore the rest of the events
self._message_queue = []
- #self._execute_stop()
- # Start removing the installed addons
- if self._runner_state == RUNNER_STATE_AWAITING_NOTIFICATIONS:
- # Start uninstalling the events
- self._unsubscribe_events()
- if self._runner_state == RUNNER_STATE_SETUP_EVENTS:
- self._uninstall_actions()
+ self._execute_stop()
elif priority == EVENT_NOTIFICATION_MSG_PRIORITY:
LOGGER.debug("TutorialRunner :: Handling stored event notification for next_state %s"%message[0])
self._handle_event(*message)
@@ -259,13 +245,13 @@ class TutorialRunner(object):
if self._state is None:
raise RuntimeError("Attempting to setupState without a state")
- self._actions = self._tutorial.get_action_dict(self._state)
+ actions = self._tutorial.get_action_dict(self._state)
- if len(self._actions) == 0:
+ if len(actions) == 0:
self.all_actions_installed()
return
- for (action_name, action) in self._actions.items():
+ for (action_name, action) in actions.items():
LOGGER.debug("TutorialRunner :: Installed action %s"%(action_name))
self._pM.install(action,
save_args(self.action_installed, action_name),
diff --git a/tutorius/translator.py b/tutorius/translator.py
index 2265ebd..13b3c61 100644
--- a/tutorius/translator.py
+++ b/tutorius/translator.py
@@ -194,8 +194,8 @@ class ResourceTranslator(object):
# Execute the replacement
self.translate(new_action)
- self._action_installed_cbs[new_action] = save_args(action_installed_cb, action)
- self._install_error_cbs[new_action] = save_args(error_cb, action)
+ self._action_installed_cbs[new_action] = action_installed_cb
+ self._install_error_cbs[new_action] = error_cb
# Send the new action to the probe manager
self._probe_manager.install(new_action, save_args(self.action_installed, new_action),