Exemplo n.º 1
0
class DefaultAgent(AbsAgent, BaseLoggingObj):
    @logger
    def regisFunc(self):
        self.findModule()
        keys = self.moduleMap.keys()
        for key in keys:
            item = self.moduleMap[key]
            if type(item) != type(Type.map):
                continue
            module = DymUtil.getModuleFromFile(item["path"], item["package"])
            clazz = DymUtil.getattr(module, key)
            target = clazz()
            export = target.list()
            if export is None:
                continue
            func_collection = export["items"]
            for each_func in func_collection:
                self.server.register_function(
                    DymUtil.getattr(target, each_func["function"]),
                    each_func["function"])
            self.listArray.append(export)
            print(export)
        self.server.register_function(self.list, "list")

    '''导出当前服务器需要的检测'''

    def list(self):
        return self.listArray

    def __init__(self, config=Config):
        self.muScanner = ModuleScanner(config)
        self.listArray = []
        BaseLoggingObj.__init__(self, config=config)
        AbsAgent.__init__(self, config=config)

    def findModule(self):
        self.muScanner.scan(Config.check_module_path)
        self.moduleMap = self.muScanner.moduleMap
Exemplo n.º 2
0
class DefaultAgent(AbsAgent, BaseLoggingObj):
    @logger
    def regisFunc(self):
        self.findModule()
        keys = self.moduleMap.keys()
        for key in keys:
            item = self.moduleMap[key]
            if type(item) != type(Type.map):
                continue
            module = DymUtil.getModuleFromFile(item["path"], item["package"])
            clazz = DymUtil.getattr(module, key)
            target = clazz()
            export = target.list()
            if export is None:
                continue
            func_collection = export["items"]
            for each_func in func_collection:
                self.server.register_function(DymUtil.getattr(target, each_func["function"]), each_func["function"])
            self.listArray.append(export)
            print(export)
        self.server.register_function(self.list, "list")

    '''导出当前服务器需要的检测'''

    def list(self):
        return self.listArray

    def __init__(self, config=Config):
        self.muScanner = ModuleScanner(config)
        self.listArray = []
        BaseLoggingObj.__init__(self, config=config)
        AbsAgent.__init__(self, config=config)

    def findModule(self):
        self.muScanner.scan(Config.check_module_path)
        self.moduleMap = self.muScanner.moduleMap
Exemplo n.º 3
0
 def initModule(self):
     ms = ModuleScanner()
     self.module = ms.scan(self.config.install_module_path)