Ejemplo n.º 1
0
def load_plugins():
    plugin_types = rlist_classes('rift.plugins', is_plugin)
    plugins = []
    for plugin_type in plugin_types:
        try:
            plugin = plugin_type()
            plugins.append(plugin)
        except TypeError as error:
            print('Could not load plugin: {type}\n * {error}'.format(
                  type=plugin_type, error=error))
    return plugins
Ejemplo n.º 2
0
def load_plugins():
    plugin_types = rlist_classes('rift.plugins', is_plugin)
    plugins = []
    for plugin_type in plugin_types:
        try:
            plugin = plugin_type()
            plugins.append(plugin)
        except TypeError as error:
            print('Could not load plugin: {type}\n * {error}'.format(
                type=plugin_type, error=error))
    return plugins
Ejemplo n.º 3
0
    def test_recursively_listing_classes_with_filter(self):
        test_module = pynsive.import_module('pynsive_test.test_classes')

        def subclasses_only(test_type):
            same = test_type is not test_module.PynsiveTestingClass
            is_subclass = issubclass(
                test_type, test_module.PynsiveTestingClass)
            print('test class - {}'.format(test_type))
            print(same)
            print(is_subclass)
            return not same and is_subclass

        classes = pynsive.rlist_classes('pynsive_test', subclasses_only)
        self.assertEqual(len(classes), 1)
Ejemplo n.º 4
0
    def scan(self, search_path=None, module_name=None):
        search_path = search_path or self.search_path
        search_path = path.abspath(search_path)
        module = path.split(search_path)[1]

        if not path.exists(path.join(search_path)):
            return []

        self.plugin_manager.plug_into(path.split(search_path)[0])

        classes = rlist_classes(module, cls_filter=Describe.plugin_filter)
        if module_name:
            classes = self.filter_by_module_name(classes, module_name)

        return classes
Ejemplo n.º 5
0
 def get_reporters_classes(self):
     return rlist_classes('specter.reporting', self.reporter_filter)
Ejemplo n.º 6
0
 def test_recursively_discovering_classes(self):
     classes = pynsive.rlist_classes('pynsive_test')
     self.assertEqual(4, len(classes))