當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。