dbus service : removing the method cloudeebus.Service.add
[contrib/cloudeebus.git] / cloudeebus / cloudeebus.py
index a432f07..4e046d7 100755 (executable)
@@ -51,7 +51,7 @@ from xml.etree.ElementTree import XMLParser
 
 ###############################################################################
 
-VERSION = "0.3.2"
+VERSION = "0.5.1"
 OPENDOOR = False
 CREDENTIALS = {}
 WHITELIST = []
@@ -278,6 +278,10 @@ class XmlCbParser: # The target object of the parser
 
 
        
+###############################################################################
+def createClassName(objectPath):
+    return re.sub('/', '_', objectPath[1:])
+
 ################################################################################       
 class DynDBusClass():
     def __init__(self, className, globalCtx, localCtx):
@@ -571,7 +575,13 @@ class CloudeebusService:
                'errorCB': async_error_cb}
         if methodId not in self.servicePendingCalls:
             self.servicePendingCalls[methodId] = {'count': 0, 'calls': []}
-        pendingCallStr = json.dumps({'callIndex': len(self.servicePendingCalls[methodId]['calls']), 'args': args})
+            
+        try:
+            pendingCallStr = json.dumps({'callIndex': len(self.servicePendingCalls[methodId]['calls']), 'args': args})
+        except Exception, e:                
+            args = eval( str(args).replace("dbus.Byte", "dbus.Int16") )
+            pendingCallStr = json.dumps({'callIndex': len(self.servicePendingCalls[methodId]['calls']), 'args': args})
+               
         self.servicePendingCalls[methodId]['calls'].append(cb)
         self.servicePendingCalls[methodId]['count'] = self.servicePendingCalls[methodId]['count'] + 1
         factory.dispatch(methodId, pendingCallStr)
@@ -582,7 +592,7 @@ class CloudeebusService:
         arguments: busName, srvName
         '''
         busName = list[0]
-        self.bus =  cache.dbusConnexion( busName['name'] )
+        self.bus =  cache.dbusConnexion( busName )
         self.srvName = list[1]
         if (self.services.has_key(self.srvName) == False):            
             self.services[self.srvName] = dbus.service.BusName(name = self.srvName, bus = self.bus)
@@ -607,7 +617,7 @@ class CloudeebusService:
         '''
         self.agentObjectPath = list[0]
         xmlTemplate = list[1]
-        self.className = re.sub('/', '_', self.agentObjectPath[1:])
+        self.className = createClassName(self.agentObjectPath)
         if (self.dynDBusClasses.has_key(self.className) == False):
             self.dynDBusClasses[self.className] = DynDBusClass(self.className, self.globalCtx, self.localCtx)
             self.dynDBusClasses[self.className].createDBusServiceFromXML(xmlTemplate)
@@ -626,7 +636,7 @@ class CloudeebusService:
         arguments: objectPath, xmlTemplate
         '''
         agentObjectPath = list[0]
-        className = re.sub('/', '_', agentObjectPath[1:])
+        className = createClassName(agentObjectPath)
 
         if (self.serviceAgents.has_key(className)):
             self.serviceAgents[self.className].remove_from_connection()