diff options
author | vidon | 2004-10-21 20:49:28 +0000 |
---|---|---|
committer | vidon | 2004-10-21 20:49:28 +0000 |
commit | a663d00b712d4d916bb8a3e0cdf7ed8cac1bafab (patch) | |
tree | 20bd9a920512d205fb2918bd12218a00ad00c6b7 | |
parent | a5e96aeeb099065b7479ac66760397c3cb722b50 (diff) | |
download | ivycpy-a663d00b712d4d916bb8a3e0cdf7ed8cac1bafab.zip ivycpy-a663d00b712d4d916bb8a3e0cdf7ed8cac1bafab.tar.gz ivycpy-a663d00b712d4d916bb8a3e0cdf7ed8cac1bafab.tar.bz2 ivycpy-a663d00b712d4d916bb8a3e0cdf7ed8cac1bafab.tar.xz |
Support des exceptions survenant dans les callbacks integré au wrapper
-rw-r--r-- | ivy.py | 89 | ||||
-rw-r--r-- | ivycpy.i | 27 |
2 files changed, 47 insertions, 69 deletions
@@ -86,24 +86,16 @@ class Ivy: IvyException(str(x))() def _appliCallback(self, ivyclient, connected): - #TODO - #Suivant le type ( connexion ou deconnexion ) - ##appeler _connect ou _disconnect - try: - if not self.dIvyClient.has_key(ivyclient): - ivyClient=Ivy.IvyClient(ivyclient) - self.dIvyClient[ivyclient]=ivyClient - else: - ivyClient=self.dIvyClient[ivyclient] - - if connected == ivycpy.IvyApplicationConnected: - self._connect(ivyClient) - else: - self._disconnect(ivyClient) - except : - res=apply(traceback.format_exception, sys.exc_info()) - print res - + if not self.dIvyClient.has_key(ivyclient): + ivyClient=Ivy.IvyClient(ivyclient) + self.dIvyClient[ivyclient]=ivyClient + else: + ivyClient=self.dIvyClient[ivyclient] + + if connected == ivycpy.IvyApplicationConnected: + self._connect(ivyClient) + else: + self._disconnect(ivyClient) def _connect(self, *arg): for listener in self.lIvyApplicationlisteners: @@ -115,31 +107,22 @@ class Ivy: def _die(self,ivyclient): try: - try: - ivyClient=self.dIvyClient[ivyclient] - except KeyError: - ivyClient=Ivy.IvyClient(ivyclient) - self.dIvyClient[ivyclient]=ivyClient - - for listener in self.lIvyApplicationlisteners: - listener.die(ivyclient) - except: - res=apply(traceback.format_exception, sys.exc_info()) - print res + ivyClient=self.dIvyClient[ivyclient] + except KeyError: + ivyClient=Ivy.IvyClient(ivyclient) + self.dIvyClient[ivyclient]=ivyClient + + for listener in self.lIvyApplicationlisteners: + listener.die(ivyclient) def _directMessage(self, ivyclient, *arg): try: - try: - ivyClient=self.dIvyClient[ivyclient] - except KeyError: - ivyClient=Ivy.IvyClient(ivyclient) - self.dIvyClient[ivyclient]=ivyClient - for listener in self.lIvyApplicationlisteners: - listener.directMessage(ivyClient,*arg) - except: - res=apply(traceback.format_exception, sys.exc_info()) - print res - + ivyClient=self.dIvyClient[ivyclient] + except KeyError: + ivyClient=Ivy.IvyClient(ivyclient) + self.dIvyClient[ivyclient]=ivyClient + for listener in self.lIvyApplicationlisteners: + listener.directMessage(ivyClient,*arg) def bindMsg(self, regexp, aIvyMessageListener): id=ivycpy.IvyBindMsg(aIvyMessageListener.receive, @@ -181,32 +164,6 @@ class Ivy: self.dIvyClient[ivyclient]=ivyClient return ivyClient -# public interface IvyApplicationListener extends java.util.EventListener { -# /** -# * invoked when a Ivy Client has joined the bus -# * @param client the peer -# */ -# public abstract void connect(IvyClient client); -# /** -# * invoked when a Ivy Client has left the bus -# * @param client the peer -# */ -# public abstract void disconnect(IvyClient client); -# /** -# * invoked when a peer request us to leave the bus -# * @param client the peer -# */ -# public abstract void die(IvyClient client, int id); -# /** -# * invoked when a peer sends us a direct message -# * @param client the peer -# * @param id -# * @param msgarg the message itself -# * this is not yet implemented in java. I believe it has no real use :) -# */ -# public abstract void directMessage( IvyClient client, int id,String msgarg ); -# } - class IvyApplicationAdapter : """IvyApplicationAdapter Classe d'objets abstraite définissant l'interface des objets à fournir à l'objet de classe Ivy @@ -288,6 +288,9 @@ pytkIvyApplicationCallback(IvyClientPtr app, void *user_data, PyTuple_SetItem(arglist,1,eventobj); result = PyEval_CallObject(func,arglist); + if(PyErr_Occurred()){ + PyErr_Print(); + } Py_DECREF(arglist); } @@ -320,6 +323,9 @@ pyIvyApplicationCallback(IvyClientPtr app, void *user_data, PyTuple_SetItem(arglist,1,eventobj); result = PyEval_CallObject(func,arglist); + if(PyErr_Occurred()){ + PyErr_Print(); + } Py_DECREF(arglist); } static void @@ -354,6 +360,9 @@ pytkIvyDieCallback(IvyClientPtr app, void *user_data, int id) PyTuple_SetItem(arglist,1,idobj); result = PyEval_CallObject(func,arglist); + if(PyErr_Occurred()){ + PyErr_Print(); + } Py_DECREF(arglist); } @@ -387,6 +396,9 @@ pyIvyDieCallback(IvyClientPtr app, void *user_data, int id) PyTuple_SetItem(arglist,1,idobj); result = PyEval_CallObject(func,arglist); + if(PyErr_Occurred()){ + PyErr_Print(); + } Py_DECREF(arglist); } @@ -430,6 +442,9 @@ pytkMsgCallback( IvyClientPtr app, void *user_data, int argc, char **argv ) Py_DECREF(arglist); */ result = PyEval_CallObject(func, pyargv) ; + if(PyErr_Occurred()){ + PyErr_Print(); + } Py_DECREF(pyargv); } @@ -480,7 +495,9 @@ pyMsgCallback( IvyClientPtr app, void *user_data, int argc, char **argv ) to the Python call back */ result = PyEval_CallObject(func, pyargv) ; - printf("-pytkMsgCallback 3\n"); + if(PyErr_Occurred()){ + PyErr_Print(); + } Py_DECREF(pyargv); /*Py_DECREF(resultobj);*/ } @@ -517,8 +534,10 @@ pytkMsgDirectCallback( IvyClientPtr app, void *user_data, int id, char *msg ) PyTuple_SetItem(arglist,1,PyString_FromString(msg)); result = PyEval_CallObject(func,arglist); + if(PyErr_Occurred()){ + PyErr_Print(); + } Py_DECREF(arglist); - Py_DECREF(resultobj); } static void @@ -550,8 +569,10 @@ pyMsgDirectCallback( IvyClientPtr app, void *user_data, int id, char *msg ) PyTuple_SetItem(arglist,1,PyString_FromString(msg)); result = PyEval_CallObject(func,arglist); + if(PyErr_Occurred()){ + PyErr_Print(); + } Py_DECREF(arglist); - Py_DECREF(resultobj); } /* facade to IvyBindMsg avoiding vararg problem */ |