aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvidon2004-10-21 11:05:00 +0000
committervidon2004-10-21 11:05:00 +0000
commit1d9ef81c6f5aa492c2d2c2fc985eb26ebd5c88f9 (patch)
tree9367b5168bb5e5bdd328c9a39b21d86018855af7
parent72bc518160d1d4e1ce996d5bb1a76f28551f5781 (diff)
downloadivycpy-1d9ef81c6f5aa492c2d2c2fc985eb26ebd5c88f9.zip
ivycpy-1d9ef81c6f5aa492c2d2c2fc985eb26ebd5c88f9.tar.gz
ivycpy-1d9ef81c6f5aa492c2d2c2fc985eb26ebd5c88f9.tar.bz2
ivycpy-1d9ef81c6f5aa492c2d2c2fc985eb26ebd5c88f9.tar.xz
Protection des callbacks afin de voir passer les exceptions
Correction d'un bogue sur la création des objets de type Ivy.IvyClient
-rw-r--r--ivy.py74
1 files changed, 46 insertions, 28 deletions
diff --git a/ivy.py b/ivy.py
index 05de4a7..869239b 100644
--- a/ivy.py
+++ b/ivy.py
@@ -7,6 +7,8 @@ import threading
#Idée : A la connexion : On crée l'objet Python, à la déconnexion on le détruit
#A la reception d'un message, on recherche l'objet python associéa
import ivycpy
+import sys
+import traceback
class Ivy:
class IvyClient:
def __init__(self, ptr):
@@ -87,16 +89,22 @@ class Ivy:
#TODO
#Suivant le type ( connexion ou deconnexion )
##appeler _connect ou _disconnect
- if not self.dIvyClient.has_key(ivyclient):
- ivyClient=IvyClient(ivyclient)
- self.dIvyClient[ivyclient]=ivyClient
- else:
- ivyClient=dIvyClient[ivyclient]
- if connected == ivycpy.IvyApplicationDisceonnected:
- self._connect(ivyClient)
- else:
- self._disconnect(ivyClient)
-
+ try:
+ if not self.dIvyClient.has_key(ivyclient):
+ ivyClient=Ivy.IvyClient(ivyclient)
+ self.dIvyClient[ivyclient]=ivyClient
+ else:
+ ivyClient=dIvyClient[ivyclient]
+
+ if connected == ivycpy.IvyApplicationConnected:
+ self._connect(ivyClient)
+ else:
+ self._disconnect(ivyClient)
+ except :
+ res=apply(traceback.format_exception, sys.exc_info())
+ print res
+
+
def _connect(self, *arg):
for listener in self.lIvyApplicationlisteners:
listener.connect(*arg)
@@ -107,27 +115,37 @@ class Ivy:
def _die(self,ivyclient):
try:
- ivyClient=dIvyClient[ivyclient]
- except KeyError:
- ivyClient=IvyClient(ivyclient)
- self.dIvyClient[ivyclient]=ivyClient
-
- for listener in self.lIvyApplicationlisteners:
- listener.die(ivyclient)
+ try:
+ ivyClient=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
def _directMessage(self, ivyclient, *arg):
try:
- ivyClient=dIvyClient[ivyclient]
- except KeyError:
- ivyClient=IvyClient(ivyclient)
- self.dIvyClient[ivyclient]=ivyClient
- for listener in self.lIvyApplicationlisteners:
- listener.directMessage(ivyClient,*arg)
+ try:
+ ivyClient=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
+
def bindMsg(self, regexp, aIvyMessageListener):
id=ivycpy.IvyBindMsg(aIvyMessageListener.receive,
regexp)
self.dRegexp[regexp]=id
+ return id
def unBindMsg(self, param):
if type(param) == type(1):
@@ -195,17 +213,17 @@ class IvyApplicationAdapter :
lors de son initialisation et par les methodes addApplicationListener et removeApplicationListener
"""
- def connect(self):
+ def connect(self,client):
pass
- def disconnect():
+ def disconnect(self,client):
pass
- def die(id):
+ def die(self,id):
pass
- def directMessage(id, msgarg):
+ def directMessage(self, id, msg):
pass
class IvyMessageAdapter:
- def receive(*arg):
+ def receive(self, *arg):
pass
class IvyException :