From bea085a5f9ad96d3d9dad0dd8f71b5e57e7c64ab Mon Sep 17 00:00:00 2001 From: mike Date: Sun, 15 Nov 2009 03:43:02 +0000 Subject: Repairing ProbeManager interface Fixing import in Translator, removing *_all functions Added fix for reloading __name__ in the Vault (it used to be eval'ed and failed) --- diff --git a/tutorius/TProbe.py b/tutorius/TProbe.py index db31d4a..57de868 100644 --- a/tutorius/TProbe.py +++ b/tutorius/TProbe.py @@ -513,7 +513,7 @@ class ProbeManager(object): else: raise RuntimeWarning("No activity attached") - def unsubscribe(self, event, callback): + def unsubscribe(self, address): """ Unregister an event listener @param address identifier given by subscribe() diff --git a/tutorius/translator.py b/tutorius/translator.py index bc98fc5..9cd4f98 100644 --- a/tutorius/translator.py +++ b/tutorius/translator.py @@ -16,7 +16,7 @@ import os import logging -import copy +import copy as copy_module logger = logging.getLogger("ResourceTranslator") @@ -135,10 +135,10 @@ class ResourceTranslator(object): ## Unchanged functions ## def setCurrentActivity(self, activity_id): - self._probe_manager.setCurrentActivity(activity_id) + self._probe_manager.currentActivity = activity_id def getCurrentActivity(self): - return self._probe_manager.getCurrentActivity() + return self._probe_manager.currentActivity currentActivity = property(fget=getCurrentActivity, fset=setCurrentActivity) def attach(self, activity_id): @@ -150,11 +150,8 @@ class ResourceTranslator(object): def subscribe(self, event, callback): return self._probe_manager.subscribe(event, callback) - def unsubscribe(self, event, callback): - return self._probe_manager.unsubscribe(event, callback) - - def unsubscribe_all(self): - return self._probe_manager.unsubscribe_all() + def unsubscribe(self, address): + return self._probe_manager.unsubscribe(address) def register_probe(self, process_name, unique_id): self._probe_manager.register_probe(process_name, unique_id) @@ -170,7 +167,7 @@ class ResourceTranslator(object): # Make a new copy of the action that we want to install, # because translate() changes the action and we # don't want to modify the caller's action representation - new_action = copy.deepcopy(action) + new_action = copy_module.deepcopy(action) # Execute the replacement self.translate(new_action) @@ -178,17 +175,18 @@ class ResourceTranslator(object): return self._probe_manager.install(new_action, block) def update(self, action, newaction, block=False): - translated_new_action = copy.deepcopy(newaction) + # TODO : Repair this as it currently doesn't work. + # Actions are being copied, then translated in install(), so they + # won't be addressable via the same object that is in the Tutorial + # Runner. + translated_new_action = copy_module.deepcopy(newaction) self.translate(translated_new_action) return self._probe_manager.update(action, translated_new_action, block) def uninstall(self, action, block=False): - new_action = copy.deepcopy(action) + new_action = copy_module.deepcopy(action) self.translate(new_action) return self._probe_manager.uninstall(new_action, block) - def uninstall_all(self): - return self._probe_manager.uninstall_all() - diff --git a/tutorius/vault.py b/tutorius/vault.py index 4d817ec..73f98d0 100644 --- a/tutorius/vault.py +++ b/tutorius/vault.py @@ -659,13 +659,11 @@ class XMLSerializer(Serializer): new_transition = None for transition in transition_element_list: - #start_state = transition.getAttribute(START_STATE_ATTR) next_state = transition.getAttribute(NEXT_STATE_ATTR) transition_name = transition.getAttribute(NAME_ATTR) try: - #The attributes must be removed so that they are not + # The attributes must be removed so that they are not # viewed as a property in load_xml_component - # transition.removeAttribute(START_STATE_ATTR) transition.removeAttribute(NEXT_STATE_ATTR) transition.removeAttribute(NAME_ATTR) except NotFoundErr: @@ -683,13 +681,11 @@ class XMLSerializer(Serializer): new_transition = None for transition in transition_element_list: - #start_state = transition.getAttribute(START_STATE_ATTR) next_state = transition.getAttribute(NEXT_STATE_ATTR) transition_name = transition.getAttribute(NAME_ATTR) try: #The attributes must be removed so that they are not # viewed as a property in load_xml_component - # transition.removeAttribute(START_STATE_ATTR) transition.removeAttribute(NEXT_STATE_ATTR) transition.removeAttribute(NAME_ATTR) except NotFoundErr: @@ -752,7 +748,8 @@ class XMLSerializer(Serializer): properties = {} for prop in node.attributes.keys(): - if prop == "Class" : continue + if prop == "Class" or prop[:2] == '__': continue + logger.debug("property to be inserted is : " + prop) # security : keep sandboxed properties[str(prop)] = eval(node.getAttribute(prop)) -- cgit v0.9.1