当前位置: 首页>>代码示例>>Python>>正文


Python pluginbase.PluginBase方法代码示例

本文整理汇总了Python中pluginbase.PluginBase方法的典型用法代码示例。如果您正苦于以下问题:Python pluginbase.PluginBase方法的具体用法?Python pluginbase.PluginBase怎么用?Python pluginbase.PluginBase使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pluginbase的用法示例。


在下文中一共展示了pluginbase.PluginBase方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_policy

# 需要导入模块: import pluginbase [as 别名]
# 或者: from pluginbase import PluginBase [as 别名]
def get_policy(plugin_source, repository, default=True):
    """Gets policy from plugin_source.

    Args:
        plugin_source (PluginBase): the plugin source from loading plugin_base.
        repository (string): Name of repository.
        default (bool): If to load the default policy.

    Returns:
        policy (func): The policy python module.
    """
    policy_name = repository.replace("-", "_")
    try:
        policy = plugin_source.load_plugin(policy_name)
    except ImportError:
        if default:
            LOG.info("No policy found for %s. Applying Default", repository)
            policy = plugin_source.load_plugin('default')
        else:
            LOG.info("No policy found for %s. Skipping Default", repository)
            policy = None
    return policy 
开发者ID:gogoair,项目名称:lavatory,代码行数:24,代码来源:setup_pluginbase.py

示例2: __init__

# 需要导入模块: import pluginbase [as 别名]
# 或者: from pluginbase import PluginBase [as 别名]
def __init__(self):
        self.here = os.path.abspath(os.path.dirname(__file__))

        self.plugin_base = PluginBase(
            package='aws_ir.plugins',
            searchpath=[
                os.path.dirname(aws_ir_plugins.__file__),
                (os.getenv("HOME") + '/.awsir/plugins')
            ]
        )

        self.source = self.plugin_base.make_plugin_source(
            searchpath=[
                os.path.dirname(aws_ir_plugins.__file__),
                (os.getenv("HOME") + '/.awsir/plugins')
            ]
        )

        self.list = self.source.list_plugins() 
开发者ID:ThreatResponse,项目名称:aws_ir,代码行数:21,代码来源:plugin.py

示例3: load_plugins

# 需要导入模块: import pluginbase [as 别名]
# 或者: from pluginbase import PluginBase [as 别名]
def load_plugins():
    here = os.path.abspath(os.path.dirname(__file__))
    get_path = partial(os.path.join, here)
    plugin_dir = get_path('plugins')

    plugin_base = PluginBase(
        package='wafw00f.plugins', searchpath=[plugin_dir]
    )
    plugin_source = plugin_base.make_plugin_source(
        searchpath=[plugin_dir], persist=True
    )

    plugin_dict = {}
    for plugin_name in plugin_source.list_plugins():
        plugin_dict[plugin_name] = plugin_source.load_plugin(plugin_name)

    return plugin_dict 
开发者ID:EnableSecurity,项目名称:wafw00f,代码行数:19,代码来源:manager.py

示例4: disable

# 需要导入模块: import pluginbase [as 别名]
# 或者: from pluginbase import PluginBase [as 别名]
def disable(self, name):
		"""
		Disable a plugin by it's name. This call the plugins
		:py:meth:`.PluginBase.finalize` method to allow it to perform any
		clean up operations.

		:param str name: The name of the plugin to disable.
		"""
		self._lock.acquire()
		inst = self.enabled_plugins[name]
		inst.finalize()
		inst._cleanup()
		del self.enabled_plugins[name]
		self._lock.release()
		self.logger.info("plugin '{0}' has been disabled".format(name))

	# methods to deal with plugin load operations 
开发者ID:rsmusllp,项目名称:king-phisher,代码行数:19,代码来源:plugins.py

示例5: load_platform

# 需要导入模块: import pluginbase [as 别名]
# 或者: from pluginbase import PluginBase [as 别名]
def load_platform():
    """
    载入信息发布平台
    :return:
    """
    platform_dir = BASE_PATH + 'platforms'

    platform_base = PluginBase(
        package=str('platforms').replace('/', '.'), searchpath=[platform_dir]
    )
    platform_source = platform_base.make_plugin_source(
        searchpath=[platform_dir], persist=True
    )
    platform_dict = {}
    for platform_name in platform_source.list_plugins():
        __tmp = platform_source.load_plugin(platform_name)
        if hasattr(__tmp, 'Platform') and hasattr(__tmp, 'Base'):
            if platform_source.load_plugin(platform_name).Platform([]).info['status']:
                platform_dict[platform_name] = platform_source.load_plugin(platform_name)

    return platform_dict 
开发者ID:anbai-inc,项目名称:SecRss,代码行数:23,代码来源:Global.py

示例6: setup_pluginbase

# 需要导入模块: import pluginbase [as 别名]
# 或者: from pluginbase import PluginBase [as 别名]
def setup_pluginbase(extra_policies_path=None):
    """Sets up plugin base with default path and provided path

    Args:
        extra_policies_path (str): Extra path to find plugins in

    Returns:
        PluginSource: PluginBase PluginSource for finding plugins
    """
    here = pathlib.Path(__file__).parent.absolute()
    default_path_obj = here / "../policies"
    default_path = str(default_path_obj.resolve())

    all_paths = [default_path]
    if extra_policies_path:
        extra_policies_obj = pathlib.Path(extra_policies_path)
        if extra_policies_obj.is_dir():
            extra_policies = get_directory_path(extra_policies_obj)
            all_paths.insert(0, str(extra_policies))
        else:
            raise InvalidPoliciesDirectory
    LOG.info("Searching for policies in %s", str(all_paths))
    plugin_base = PluginBase(package='lavatory.policy_plugins')
    plugin_source = plugin_base.make_plugin_source(searchpath=all_paths)
    LOG.debug("Policies found: %s", str(plugin_source.list_plugins()))
    return plugin_source 
开发者ID:gogoair,项目名称:lavatory,代码行数:28,代码来源:setup_pluginbase.py

示例7: enable

# 需要导入模块: import pluginbase [as 别名]
# 或者: from pluginbase import PluginBase [as 别名]
def enable(self, name):
		"""
		Enable a plugin by it's name. This will create a new instance of the
		plugin modules "Plugin" class, passing it the arguments defined in
		:py:attr:`.plugin_init_args`. A reference to the plugin instance is kept
		in :py:attr:`.enabled_plugins`. After the instance is created, the
		plugins :py:meth:`~.PluginBase.initialize` method is called.

		:param str name: The name of the plugin to enable.
		:return: The newly created instance.
		:rtype: :py:class:`.PluginBase`
		"""
		self._lock.acquire()
		klass = self.loaded_plugins[name]
		if not klass.is_compatible:
			self._lock.release()
			raise errors.KingPhisherPluginError(name, 'the plugin is incompatible')
		inst = klass(*self.plugin_init_args)
		try:
			initialized = inst.initialize()
		except Exception:
			self.logger.error("failed to enable plugin '{0}', initialize threw an exception".format(name), exc_info=True)
			try:
				inst._cleanup()
			except Exception:
				self.logger.error("failed to clean up resources for plugin '{0}'".format(name), exc_info=True)
			self._lock.release()
			raise
		if not initialized:
			self.logger.warning("failed to enable plugin '{0}', initialize check failed".format(name))
			self._lock.release()
			return
		self.enabled_plugins[name] = inst
		self._lock.release()
		self.logger.info("plugin '{0}' has been enabled".format(name))
		return inst 
开发者ID:rsmusllp,项目名称:king-phisher,代码行数:38,代码来源:plugins.py

示例8: _init_manager

# 需要导入模块: import pluginbase [as 别名]
# 或者: from pluginbase import PluginBase [as 别名]
def _init_manager(self):
        if self.init:
            return
        self.plugin_base = PluginBase(package='burpui.plugins.ext')
        self.plugin_source = self.plugin_base.make_plugin_source(
            searchpath=self.searchpath
        )
        self.init = True 
开发者ID:ziirish,项目名称:burp-ui,代码行数:10,代码来源:plugins.py

示例9: get_source

# 需要导入模块: import pluginbase [as 别名]
# 或者: from pluginbase import PluginBase [as 别名]
def get_source(checker_paths=[]):
    """Load all of the checkers using pluginbase."""
    # define the "package" in which the checks reside
    # the term "package" corresponds to "module.sub-module"
    checker_base = PluginBase(package=constants.packages.Checks)
    # remove any directories from the path listings that are Nothing (i.e., "")
    # this case occurs when the optional --checkerdir is not provided on command-line
    if constants.markers.Nothing in checker_paths:
        checker_paths.remove(constants.markers.Nothing)
    # Create the directory where the internal checkers live inside of GatorGrader.
    # Note that this directory includes the home for GatorGrader, which can be set
    # by an environment variable and otherwise defaults to the directory from which
    # GatorGrader was run and then the directory where internal checkers are stored.
    internal_checker_path = files.create_path(
        constants.checkers.Internal_Checkers_Dir, home=util.get_gatorgrader_home()
    )
    # create the listing of the paths that could contain checkers, including
    # all of the provided paths for external checkers and the directory that
    # contains all of the internal checkers provided by GatorGrader
    all_checker_paths = checker_paths + [str(internal_checker_path)]
    # Create and return a source of checkers using PluginBase.
    # The documentation for this function advices that you
    # give an identifier to the source for the plugins
    # because this will support saving and transfer, if needed.
    # Only perform this operation if the checker source is None,
    # meaning that it has not already been initialized.
    # pylint: disable=global-statement
    global CHECKER_SOURCE
    if CHECKER_SOURCE is None:
        CHECKER_SOURCE = checker_base.make_plugin_source(
            identifier=constants.checkers.Plugin_Base_Identifier,
            searchpath=all_checker_paths,
        )
    return CHECKER_SOURCE 
开发者ID:GatorEducator,项目名称:gatorgrader,代码行数:36,代码来源:checkers.py

示例10: import_plugins

# 需要导入模块: import pluginbase [as 别名]
# 或者: from pluginbase import PluginBase [as 别名]
def import_plugins(plugin_mount, plugin_base_dir):
    plugin_base = PluginBase(package=plugin_mount)
    plugin_src_dirs = _get_plugin_src_dirs(plugin_base_dir)
    return plugin_base.make_plugin_source(searchpath=plugin_src_dirs) 
开发者ID:fkie-cad,项目名称:FACT_core,代码行数:6,代码来源:plugin.py

示例11: __init__

# 需要导入模块: import pluginbase [as 别名]
# 或者: from pluginbase import PluginBase [as 别名]
def __init__(self, path, args=None, library_path=constants.AUTOMATIC):
		"""
		:param tuple path: A tuple of directories from which to load plugins.
		:param tuple args: Arguments which should be passed to plugins when
			their class is initialized.
		:param str library_path: A path to use for plugins library dependencies.
			This value will be added to :py:attr:`sys.path` if it is not already
			included.
		"""
		self._lock = threading.RLock()
		self.plugin_init_args = (args or ())
		self.plugin_base = pluginbase.PluginBase(package='king_phisher.plugins.loaded')
		self.plugin_source = self.plugin_base.make_plugin_source(searchpath=path)
		self.loaded_plugins = {}
		"""A dictionary of the loaded plugins and their respective modules."""
		self.enabled_plugins = {}
		"""A dictionary of the enabled plugins and their respective instances."""
		self.logger = logging.getLogger('KingPhisher.Plugins.Manager')

		if library_path is not None:
			library_path = _resolve_lib_path(library_path)
		if library_path:
			if library_path not in sys.path:
				sys.path.append(library_path)
			library_path = os.path.abspath(library_path)
			self.logger.debug('using plugin-specific library path: ' + library_path)
		else:
			self.logger.debug('no plugin-specific library path has been specified')
		self.library_path = library_path
		"""
		The path to a directory which is included for additional libraries. This
		path must be writable by the current user.

		The default value is platform and Python-version (where X.Y is the major
		and minor versions of Python) dependant:

		:Linux:
			``~/.local/lib/king-phisher/pythonX.Y/site-packages``

		:Windows:
			``%LOCALAPPDATA%\\king-phisher\\lib\\pythonX.Y\\site-packages``
		""" 
开发者ID:rsmusllp,项目名称:king-phisher,代码行数:44,代码来源:plugins.py


注:本文中的pluginbase.PluginBase方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。