X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=src%2Fnepi%2Fresources%2Fomf%2Fapplication.py;h=37d244cdb88619bb3db0df52287022d0ede78645;hb=450b5dd0a993f63eb2ec34bbc656c558572eb44c;hp=da8f64fae1acda78f177637d2af2ad6d3eb326d7;hpb=573bc6721a33d323047f204841dd58ef2b83d195;p=nepi.git diff --git a/src/nepi/resources/omf/application.py b/src/nepi/resources/omf/application.py index da8f64fa..37d244cd 100644 --- a/src/nepi/resources/omf/application.py +++ b/src/nepi/resources/omf/application.py @@ -18,14 +18,13 @@ # Author: Alina Quereilhac # Julien Tribino -from nepi.execution.resource import ResourceManager, clsinit_copy, ResourceState, \ - reschedule_delay +from nepi.execution.resource import ResourceManager, clsinit_copy, \ + ResourceState, reschedule_delay, failtrap from nepi.execution.attribute import Attribute, Flags from nepi.resources.omf.omf_resource import ResourceGateway, OMFResource from nepi.resources.omf.node import OMFNode from nepi.resources.omf.omf_api import OMFAPIFactory - @clsinit_copy class OMFApplication(OMFResource): """ @@ -104,7 +103,6 @@ class OMFApplication(OMFResource): attr = self._attrs["stdin"] attr.set_hook = self.stdin_hook - def valid_connection(self, guid): """ Check if the connection with the guid in parameter is possible. Only meaningful connections are allowed. @@ -138,6 +136,7 @@ class OMFApplication(OMFResource): return True + @failtrap def deploy(self): """ Deploy the RM. It means nothing special for an application for now (later it will be upload sources, ...) @@ -152,11 +151,11 @@ class OMFApplication(OMFResource): if not self._omf_api : msg = "Credentials are not initialzed. XMPP Connections impossible" self.error(msg) - self.fail() - return + raise RuntimeError, msg super(OMFApplication, self).deploy() + @failtrap def start(self): """ Start the RM. It means : Send Xmpp Message Using OMF protocol to execute the application. @@ -166,8 +165,7 @@ class OMFApplication(OMFResource): if not (self.get('appid') and self.get('path')) : msg = "Application's information are not initialized" self.error(msg) - self.fail() - return + raise RuntimeError, msg if not self.get('args'): self.set('args', " ") @@ -186,11 +184,11 @@ class OMFApplication(OMFResource): except AttributeError: msg = "Credentials are not initialzed. XMPP Connections impossible" self.error(msg) - self.fail() raise super(OMFApplication, self).start() + @failtrap def stop(self): """ Stop the RM. It means : Send Xmpp Message Using OMF protocol to kill the application. @@ -202,8 +200,7 @@ class OMFApplication(OMFResource): except AttributeError: msg = "Credentials were not initialzed. XMPP Connections impossible" self.error(msg) - self.fail() - #raise + raise super(OMFApplication, self).stop() self.set_finished() @@ -212,10 +209,15 @@ class OMFApplication(OMFResource): """ Clean the RM at the end of the experiment and release the API. """ - if self._omf_api : - OMFAPIFactory.release_api(self.get('xmppSlice'), - self.get('xmppHost'), self.get('xmppPort'), - self.get('xmppPassword'), exp_id = self.exp_id) + try: + if self._omf_api : + OMFAPIFactory.release_api(self.get('xmppSlice'), + self.get('xmppHost'), self.get('xmppPort'), + self.get('xmppPassword'), exp_id = self.exp_id) + except: + import traceback + err = traceback.format_exc() + self.error(err) super(OMFApplication, self).release()