Ejemplo n.º 1
0
    def registerInstance(self, moduleName, className, objectId, *p, **k):

        # get module
        if Activator.Objects.has_key(objectId):
            raise Exception, "Object-ID already registered: %s" % (objectId)
        else:
            mod = getModuleByName(moduleName)
            if (hasattr(mod, "GetInstance")):
                Activator.Objects[objectId] = mod.GetInstance
            else:
                raise Exception, "Invalid Class: %s/%s" % (moduleName, className)

        # get class
        return getClassByName(moduleName, className)(objectId, *p, **k)
Ejemplo n.º 2
0
    def startModule(self, requestHandler, name = None):
        try:

            # start all modules
            if name is None:
                self.logger.info('Starting all Modules...')
                names = Config().get('modules', 'Modules').strip().split(',')
                for name in names:
                    name = name.strip()
                    if isTrue(Config().getExt(name, 'enabled').strip()):
                        try:
                            # check if exists
                            if ModuleManager.Modules.has_key(name):
                                raise Exception, "Module does already exist: %s" % (name)
                            # start
                            ModuleManager.Modules[name] = getClassByName(Config().get(name, 'module').strip(), Config().get(name, 'class').strip())(name)
                            ModuleManager.Modules[name].start(requestHandler, self.onModuleStop)
                        except Exception, e:
                            self.logger.error("failed to start Module %s (%s)" % (name, e))

            # start single module
            else:
Ejemplo n.º 3
0
    def startServer(self, requestHandler, name = None):
        try:

            # start all servers
            if name is None:
                self.logger.info('Starting all Servers...')
                serverNames = Config().get('server', 'Servers').strip().split(',')
                for name in serverNames:
                    name = name.strip()
                    if isTrue(Config().getExt(name, 'enabled').strip()):
                        try:
                            # check if exists
                            if ServerManager.Servers.has_key(name):
                                raise Exception, "Server does already exist: %s" % (name)
                            # start
                            ServerManager.Servers[name] = getClassByName(Config().get(name, 'module').strip(), Config().get(name, 'class').strip())(name)
                            ServerManager.Servers[name].start(requestHandler, self.onServerStop)
                        except Exception, e:
                            self.logger.error("failed to start Server %s (%s)" % (name, e))

            # start single server
            else:
Ejemplo n.º 4
0
                            # start
                            ModuleManager.Modules[name] = getClassByName(Config().get(name, 'module').strip(), Config().get(name, 'class').strip())(name)
                            ModuleManager.Modules[name].start(requestHandler, self.onModuleStop)
                        except Exception, e:
                            self.logger.error("failed to start Module %s (%s)" % (name, e))

            # start single module
            else:
                self.logger.info('Starting Module %s...' % name)
                if isTrue(Config().getExt(name, 'enabled').strip()):
                    try:
                        # check if exists
                        if ModuleManager.Modules.has_key(name):
                            raise Exception, "Module does already exist: %s" % (name)
                        # start
                        ModuleManager.Modules[name] = getClassByName(Config().get(name, 'module').strip(), Config().get(name, 'class').strip())(name)
                        ModuleManager.Modules[name].start(requestHandler, self.onModuleStop)
                    except Exception, e:
                        self.logger.error("failed to start Module %s (%s)" % (name, e))

        except Exception, e:
            self.logger.error("Exception in startModule (%s)" % (e))
            raise e

    """ -------------------------------------------------------------------- """
    """ stopModule                                                           """
    """ -------------------------------------------------------------------- """
    @synchronized(InstanceLock)
    def stopModule(self, name = None):
        try:
 def getDataAdapter(self, adapterClass):
     return getClassByName(
         '%s.%s' % (Config().get('database', 'DataAdapterPackage').strip(), adapterClass),
         adapterClass)()