Example #1
0
 def _get_func_in_module(plugin, func_name):
     mod = sys.modules[BasePlugin.get_module_name(plugin)]
     func = mod
     try:
         func_path = func_name.split('.')
         for fn in func_path:
             func = getattr(func, fn)
     except Exception as e:
         str(e)
         raise ModuleNotFoundError(
             'unable found api function \'{0}\''.format(func_name))
     return func
Example #2
0
 def _get_class_in_module(plugin, class_name):
     mod = sys.modules[BasePlugin.get_module_name(plugin)]
     cls = mod
     try:
         cls_path = class_name.split('.')
         for fn in cls_path:
             cls = getattr(cls, fn)
     except Exception as e:
         str(e)
         raise ModuleNotFoundError(
             'unable found schedule class \'{0}\''.format(class_name))
     return cls
Example #3
0
    def install_tables(self):
        # 获取模块的数据库表
        module_name = BasePlugin.get_module_name(self)
        plugin = importlib.import_module(module_name)
        plugin_tables = []
        for attribute_name in dir(plugin):
            if attribute_name.startswith('__'):
                continue
            attribute_value = getattr(plugin, attribute_name)
            if isinstance(attribute_value, type) and issubclass(
                    attribute_value, pa.database.Model):
                plugin_tables.append(attribute_value)

        for table in plugin_tables:
            BaseDBManagerPlugin._install_table(table)