- srvName = list[1]
- objectPath = list[2]
- xmlTemplate = list[3]
- className = re.sub('/', '_', objectPath[1:])
- if (self.dynDBusClass.has_key(className) == False):
- bus = cache.dbusConnexion(busName)
- dbus.service.BusName(name = srvName, bus = bus)
- self.dynDBusClass[className] = dynDBusClass(className, globals(), locals())
- self.dynDBusClass[className].createDBusServiceFromXML(xmlTemplate)
- self.dynDBusClass[className].declare()
-# self.dynDBusClass[className].p()
-
- if (self.serverObjs.has_key(className) == False):
- exe_str = "self.serverObjs[" + className +"] = " + className + "(bus, callback=self.srvCB, objName=objectPath, busName=srvName)"
- exec (exe_str, globals(), locals())
+ self.bus = cache.dbusConnexion( busName['name'] )
+ 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)
+ return self.srvName
+
+ @exportRpc
+ def serviceRelease(self, list):
+ '''
+ arguments: busName, srvName
+ '''
+ self.srvName = list[0]
+ if (self.services.has_key(self.srvName) == True):
+ self.services.pop(self.srvName)
+ return self.srvName
+ else:
+ raise Exception(self.srvName + " do not exist")
+
+ @exportRpc
+ def serviceAddAgent(self, list):
+ '''
+ arguments: objectPath, xmlTemplate
+ '''
+ self.agentObjectPath = list[0]
+ xmlTemplate = list[1]
+ self.className = re.sub('/', '_', self.agentObjectPath[1:])
+ 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)
+ self.dynDBusClasses[self.className].declare()
+
+ ## Class already exist, instanciate it if not already instanciated
+ if (self.serviceAgents.has_key(self.className) == False):
+ self.serviceAgents[self.className] = eval(self.className + "(self.bus, callback=self.srvCB, objName=self.agentObjectPath, busName=self.srvName)", self.globalCtx, self.localCtx)
+
+ self.serviceAgents[self.className].add_to_connection()
+ return (self.agentObjectPath)
+
+ @exportRpc
+ def serviceDelAgent(self, list):
+ '''
+ arguments: objectPath, xmlTemplate
+ '''
+ agentObjectPath = list[0]
+ className = re.sub('/', '_', agentObjectPath[1:])
+
+ if (self.serviceAgents.has_key(className)):
+ self.serviceAgents[self.className].remove_from_connection()
+ self.serviceAgents.pop(self.className)
+ else:
+ raise Exception(agentObjectPath + " doesn't exist!")
+
+ return (agentObjectPath)