本文整理汇总了Python中yapsy.PluginManager.PluginManagerSingleton类的典型用法代码示例。如果您正苦于以下问题:Python PluginManagerSingleton类的具体用法?Python PluginManagerSingleton怎么用?Python PluginManagerSingleton使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PluginManagerSingleton类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: load_filesystem_plugins
def load_filesystem_plugins(self):
"""Looks for *.yapsy-plugin files, loads them and returns a list
of :class:`VersionedPluginInfo \
<yapsy.VersionedPluginManager.VersionedPluginInfo>` objects
Note:
Plugin search locations:
* $(rawdisk package location)/plugins/filesystems
* $(home dir)/.local/share/rawdisk/plugins/filesystems
* /usr/local/share/rawdisk/plugins/filesystems
* /usr/share/rawdisk/plugins/filesystems
"""
self.logger.info('Loading filesystem plugins')
search_path = self.__get_fs_plugin_search_path()
fs_plugins = []
PluginManagerSingleton.setBehaviour([
VersionedPluginManager,
])
# Load the plugins from the plugin directory.
plugin_manager = PluginManagerSingleton.get()
plugin_manager.setPluginPlaces(search_path)
plugin_manager.setCategoriesFilter({
"Filesystem": IFilesystemPlugin,
})
# Load plugins
plugin_manager.collectPlugins()
for pluginInfo in plugin_manager.getPluginsOfCategory("Filesystem"):
fs_plugins.append(pluginInfo)
return fs_plugins
开发者ID:dariusbakunas,项目名称:rawdisk,代码行数:34,代码来源:plugin_manager.py
示例2: __init__
def __init__(self):
"""
Initialize the PluginManager including:
- plugin configuration directory
- plugin search locations
"""
self.config_path = save_config_path("yasibo")
self.config_file = os.path.join(self.config_path, "plugins.conf")
places = []
[places.append(os.path.join(path, "yasibo", "plugins")) for path in xdg_data_dirs]
# dev location
places.append("%s/../plugins" % os.path.dirname(os.path.abspath(__file__)))
PluginManagerSingleton.setBehaviour([ConfigurablePluginManager,
VersionedPluginManager])
self.manager = PluginManagerSingleton.get()
locator = self.manager.getPluginLocator()
locator.setPluginInfoExtension("yasibo-plugin")
self.manager.setPluginPlaces(places)
self.config = SafeConfigParser()
self.config.read(self.config_file)
self.manager.setConfigParser(self.config, self.save)
self.manager.collectPlugins()
log.debug("Config file: %s" % self.config_file)
开发者ID:Yasibo,项目名称:yasibo,代码行数:26,代码来源:__init__.py
示例3: _init_plugin_engine
def _init_plugin_engine(self):
self.debug("Initializing plugin engine")
places = []
if hasattr(self, '_plugin_dir'):
# run_local.py will pass in a plugin directory
places.append(self._plugin_dir)
for path in xdg_data_dirs:
path = os.path.join(path, self._package, "plugins")
places.append(path)
PluginManagerSingleton.setBehaviour([
ConfigurablePluginManager,
VersionedPluginManager,
])
manager = PluginManagerSingleton.get()
manager.application = self
manager.setConfigParser(self._config, self.write_config)
manager.setPluginInfoExtension("plugin")
manager.setPluginPlaces(places)
#manager.setCategoriesFilter({
# "Application" : WindowPlugin,
#})
manager.collectPlugins()
#for info in manager.getPluginsOfCategory("Window"):
for info in manager.getAllPlugins():
plugin = info.plugin_object
plugin.application = self
开发者ID:MicahCarrick,项目名称:mykiss,代码行数:30,代码来源:application.py
示例4: _load_filesystem_plugins
def _load_filesystem_plugins(self):
# import logging
# logging.basicConfig(level=logging.DEBUG)
"""Looks for *.yapsy-plugin files and loads them. It calls 'register' \
method for each plugin, which in turn registers with \
:class:`FilesystemDetector \
<rawdisk.filesystems.detector.FilesystemDetector>`.
Note:
Plugin search locations:
* $(rawdisk package location)/plugins/filesystems
* $(home dir)/.local/share/rawdisk/plugins/filesystems
* /usr/local/share/rawdisk/plugins/filesystems
* /usr/share/rawdisk/plugins/filesystems
"""
PluginManagerSingleton.setBehaviour([
VersionedPluginManager,
])
# Load the plugins from the plugin directory.
self.manager = PluginManagerSingleton.get()
self.manager.setPluginPlaces(self.search_path)
self.manager.setCategoriesFilter({
"Filesystem": IFilesystemPlugin,
})
# Load plugins
self.manager.collectPlugins()
for pluginInfo in self.manager.getPluginsOfCategory("Filesystem"):
self.fs_plugins.append(pluginInfo)
开发者ID:techtonik,项目名称:rawdisk,代码行数:32,代码来源:manager.py
示例5: deferred_botmsg
def deferred_botmsg(self, user, channel, task, args):
if task == "rep":
user = user.split("!")[0]
if args[0] == "give":
manager = PluginManagerSingleton.get()
user_stat = yield manager.app.is_user_online(args[1])
if user_stat == False:
logging.warning(manager.app.is_user_online(args[1]))
manager.app.msg(channel, "This user doesn't appear to be here!")
return
if args[1] == user:
manager.app.msg(channel, "You cannot give yourself rep.")
return
lastRep = manager.app.plugin_get_setting("repPlugin", "lastRep")
if user + ":" + args[1] == str(lastRep):
manager.app.msg(channel, "You've already given this person rep!")
return
self.give_rep(args[1])
manager.app.plugin_set_setting("repPlugin", "lastRep", user + ":" + args[1])
manager.app.msg(channel, args[1] + " has received 1 rep from " + user)
elif args[0] == "check":
manager = PluginManagerSingleton.get()
manager.app.msg(channel, args[1] + " has " + str(self.get_rep(args[1])) + " rep!")
elif args[0] == "purge":
manager = PluginManagerSingleton.get()
if user in manager.app.plugin_get_setting("repPlugin", "allowedUsers"):
self.cleanup()
manager.app.msg(channel, "Rep data purged.")
开发者ID:Aurora0000,项目名称:chatterpy,代码行数:28,代码来源:repPlugin.py
示例6: __init__
def __init__ (self):
""" Class initialiser """
# Get singleton instance
PluginManagerSingleton.setBehaviour([
VersionedPluginManager,
])
manager = PluginManagerSingleton.get()
# A referrence for plugins to access the app
manager.app = self
# Set environment
self.env = jinja2.Environment(loader=jinja2.FileSystemLoader("./template/"),
**TEMPLATE_OPTIONS)
# Set ArgParser
self.parser = argparse.ArgumentParser(description='Simple Static Web Generator')
self.parser.add_argument('--cache', dest='cache', action='store_true')
# A referrence for plugins to access the env object
# manager.env = self.env
# Set plugin's directories path
manager.setPluginPlaces(['plugins'])
# Locates and Loads the plugins
manager.collectPlugins()
开发者ID:mashhadlug,项目名称:pug,代码行数:27,代码来源:webtastic.py
示例7: botmsg
def botmsg(self, user, channel, task, args):
manager = PluginManagerSingleton.get()
if user.split("!")[0] not in manager.app.plugin_get_setting("pluginAdmin", "allowedUsers") and task == "plugin" :
manager.app.msg(channel, "You're not authorised to do that!")
return
if task == "plugin":
if args[0] == "rehash":
manager.app.rehash_plugins()
manager.app.msg(channel, "Plugins rehashed!")
elif args[0] == "load":
manager = PluginManagerSingleton.get()
pname = string.join(args[1:])
if pname in manager.app.plugin_get_setting("pluginAdmin", "disallowedPlugins"):
manager.app.msg(channel, "Plugin \"" + pname + "\" is protected!")
return
manager.app.load_plugin(pname)
manager.app.msg(channel, "Plugin \"" + string.join(args[1:]) + "\" has been loaded.")
elif args[0] == "unload":
manager = PluginManagerSingleton.get()
pname = string.join(args[1:])
if pname in manager.app.plugin_get_setting("pluginAdmin", "disallowedPlugins"):
manager.app.msg(channel, "Plugin \"" + pname + "\" is protected!")
return
manager.app.unload_plugin(string.join(args[1:]))
manager.app.msg(channel, "Plugin \"" + string.join(args[1:]) + "\" has been unloaded.")
开发者ID:Aurora0000,项目名称:chatterpy,代码行数:25,代码来源:pluginAdmin.py
示例8: botmsg
def botmsg(self, user, channel, task, args):
user = user.split("!")[0]
if task == "note" and args[0] == "send":
manager = PluginManagerSingleton.get()
self.add_note(args[1], "\"" + string.join(args[2:]) + "\" (from " + user + ")")
manager.app.msg(args[1], "You have a new note! Use !note read to read it.")
manager.app.msg(user, "Your message has been sent.")
elif task == "note" and args[0] == "read":
manager = PluginManagerSingleton.get()
_notes = manager.app.plugin_get_setting("notePlugin", "notes")
x = None
try:
x = _notes[user]
if len(x) == 0:
raise KeyError("x")
except KeyError:
manager.app.msg(user, "You don't have any messages.")
return
manager.app.msg(user, str(x[0]))
_notes[user].remove(x[0])
manager.app.msg(user, "You now have " + str(len(x)) + " messages. Use !note read to read the next one.")
if len(x) == 0:
_notes.pop(user, None)
manager.app.plugin_set_setting("notePlugin", "notes", _notes)
elif task == "note" and args[0] == "purge":
manager = PluginManagerSingleton.get()
if not user in manager.app.plugin_get_setting("notePlugin", "allowedUsers"):
return
self.cleanup()
manager.app.msg(user, "Notes purged.")
开发者ID:Aurora0000,项目名称:chatterpy,代码行数:30,代码来源:notePlugin.py
示例9: _loadPlugins
def _loadPlugins(self):
PluginManagerSingleton.setBehaviour([
VersionedPluginManager,
])
manager = PluginManagerSingleton.get()
manager.setPluginPlaces(self.pluginDirs)
manager.setCategoriesFilter(pluginCategories)
manager.collectPlugins()
开发者ID:miheerdew,项目名称:SalesMan,代码行数:8,代码来源:__init__.py
示例10: testActivationAndDeactivation
def testActivationAndDeactivation(self):
"""
Test if the activation/deactivaion procedures work.
"""
self.plugin_activate()
PluginManagerSingleton.get().deactivatePluginByName(self.plugin_info.name,
self.plugin_info.category)
self.assertTrue(not self.plugin_info.plugin_object.is_activated)
开发者ID:PGower,项目名称:yapsy,代码行数:8,代码来源:test_Singleton.py
示例11: plugin_activate
def plugin_activate(self):
"""
Activate the plugin with basic checking
"""
self.plugin_loading_check()
if not self.plugin_info.plugin_object.is_activated:
PluginManagerSingleton.get().activatePluginByName(self.plugin_info.name,
self.plugin_info.category)
self.assertTrue(self.plugin_info.plugin_object.is_activated)
开发者ID:PGower,项目名称:yapsy,代码行数:9,代码来源:test_Singleton.py
示例12: __init__
def __init__(self, win):
self.app = win.app
self.parent = win
# Build a list of directories which may contain plugins. This will
# include the 'plugins' folder where this file resides as well as every
# directory in xdg.BaseDirectory.xdg_data_dirs. This way users can
# install plugins in something like ~/.local/yapsy-gtk-example/plugins
# but your installer could also install those plugins to something like
# /usr/share/yapsy-gtk-example/plugins. You'll see Yapsy checking each
# of these directories if logging is set to logging.DEBUG
xdg_data_dirs = [os.path.join(os.path.expanduser("~"),
'.local', 'share')]
this_dir = os.path.abspath(self.app.FULL_PATH)
plugin_dir = os.path.join(this_dir, 'data', 'plugins')
places = [plugin_dir, ]
for path in xdg_data_dirs:
places.append(os.path.join(path, self.app.APP_NAME, "plugins"))
# The singleton versino of the Yapsy plugin manager is used rather than
# passing around a PluginManager instance. Prior to getting the
# singleton instance, some "plugin manager decorators" are installed to:
# 1. Automatically save active and non-active plugins to the config file
# 2. Ensure only the newest versions of plugins are used.
# This call to setBehaviour() must occur before getting the singleton
# instance.
PluginManagerSingleton.setBehaviour([
ConfigurablePluginManager,
VersionedPluginManager,
])
# Get singleton instance
manager = PluginManagerSingleton.get()
# I like to give the manager a reference to the application class so
# that plugins can connect to signals and access windows through
# the manager singleton.
manager.app = self.app
manager.parent = self.parent
# Give manager the config file and a callback function to call when it
# changes the config (eg. when a plugin is activated or deactivated).
manager.setConfigParser(self.app.config, self.app.config.write_settings)
# Setup a file extension for plugin information files. In this it's
# just ".plugin" but you may want to do something specific to your
# application like ".myapp-plugin"
manager.setPluginInfoExtension("gs-plugin")
# Pass the manager the list of plugin directories
manager.setPluginPlaces(places)
# CollectPlugins is a shortcut for locatePlugins() and loadPlugins().
manager.collectPlugins()
开发者ID:183amir,项目名称:gahshomar,代码行数:55,代码来源:gs_plugin_manager.py
示例13: create_plugin_manager
def create_plugin_manager(self):
from yapsy.ConfigurablePluginManager import ConfigurablePluginManager
from yapsy.PluginManager import PluginManagerSingleton
from yapsy.VersionedPluginManager import VersionedPluginManager
PluginManagerSingleton.setBehaviour([
ConfigurablePluginManager,
VersionedPluginManager,
])
return PluginManagerSingleton.get()
开发者ID:mattab,项目名称:tomate,代码行数:11,代码来源:plugin.py
示例14: __init__
def __init__(self, cfg):
"""
Initialise the plugin system.
"""
assert cfg
self.cfg = cfg
# Get plugin locations.
plugin_search_path_b = self.cfg.get_config_str(
"PluginSearchPath",
default=b"/etc/rdiffweb/plugins")
# Determine the search path
searchpath = []
# Append core plugins directory (in bytes)
path_b = pkg_resources.resource_filename('rdiffweb', b'plugins') # @UndefinedVariable
searchpath.append(path_b)
# Append user plugins directory
plugin_locations = plugin_search_path_b.split(b',')
searchpath.extend(plugin_locations)
# Build the manager
logger.debug("plugin search path [%s]" % (searchpath))
# Create the plugin manager.
PluginManagerSingleton.setBehaviour([FilteredPluginManager])
self.manager = PluginManagerSingleton.get()
# Sets plugins locations.
plugin_locator = PluginLocator()
self.manager.setPluginLocator(plugin_locator)
plugin_locator.setPluginPlaces(searchpath)
# Define categories
self.manager.setCategoriesFilter({
IDatabase.CATEGORY: IDatabase,
IDeamonPlugin.CATEGORY: IDeamonPlugin,
ILocationsPagePlugin.CATEGORY: ILocationsPagePlugin,
IPasswordStore.CATEGORY: IPasswordStore,
IPreferencesPanelProvider.CATEGORY: IPreferencesPanelProvider,
IUserChangeListener.CATEGORY: IUserChangeListener,
})
# Set filter.
self.manager.isPluginOk = self.is_plugin_enabled
# Load all plugins
self.manager.collectPlugins()
开发者ID:fliphess,项目名称:rdiffweb,代码行数:48,代码来源:rdw_plugin.py
示例15: list
def list(args):
xh.setuputil.collectPlugins()
pm = PluginManagerSingleton.get()
pluginInfoStr = 'Plugins:'
for p in pm.getAllPlugins():
infos = ['%s (%s%s)'
% (p.name, os.path.basename(p.path), os.path.sep)]
if '?' not in p.version:
infos.append('v' + p.version)
if p.description is not None:
infos.append(p.description)
pluginInfoStr += '\n\t' + ' '.join(infos)
log.info(pluginInfoStr)
serialDevice = (xh.setuputil.FAKE_SERIAL if args.fakeSerial
else args.serialDevice)
nodeInfoList = listNodeIds(
serialDevice=serialDevice,
timeout=args.timeout)
nodeInfoStr = 'XBees:'
for n in nodeInfoList:
lineStr = str(n)
nodeInfoStr += '\n\t' + lineStr
log.info(nodeInfoStr)
开发者ID:bsparacino,项目名称:xbee-homeautomation,代码行数:25,代码来源:xh.py
示例16: __init__
def __init__(self):
LogObject.__init__(self)
super(MykissPlugin, self).__init__()
# grab the application instance from the plugin manager
manager = PluginManagerSingleton.get()
self.application = manager.application
开发者ID:MicahCarrick,项目名称:mykiss,代码行数:7,代码来源:plugin.py
示例17: __init__
def __init__(self):
self.servers = {}
self.clients = []
self.logger = logging.getLogger("Factory")
self.plugman = PluginManagerSingleton.get()
self.events = manager.manager()
self.plugman.setPluginPlaces(["plugins"])
self.plugman.setPluginInfoExtension("plug")
self.plugman.collectPlugins()
self.logger.info("Loading plugins..")
for pluginInfo in self.plugman.getAllPlugins():
try:
self.plugman.activatePluginByName(pluginInfo.name)
pluginInfo.plugin_object._add_variables(pluginInfo, self)
pluginInfo.plugin_object.setup()
except Exception:
self.logger.warn("Unable to load plugin: %s v%s" % (pluginInfo.name, pluginInfo.version))
util.output_exception(self.logger, logging.WARN)
self.plugman.deactivatePluginByName(pluginInfo.name)
else:
self.logger.info("Loaded plugin: %s v%s" % (pluginInfo.name, pluginInfo.version))
event = pluginLoadedEvent(self, pluginInfo)
self.events.runCallback("pluginLoaded", event)
self.logger.info("Finished loading plugins.")
event = pluginsLoadedEvent(self)
self.events.runCallback("pluginsLoaded", event)
开发者ID:TheArchives,项目名称:Inter,代码行数:28,代码来源:core.py
示例18: __init__
def __init__(self, parent):
super(SettingsDialog,self).__init__(parent)
pluginPaths = wx.GetApp().GetPluginPlaces()
self.pluginsHtml.SetPage(
"""
<html>
<body><h3 align="center">Select Plugins</h3>
You can add customized plugins by placing them in the following
directories <ul><li>{}<li>{}</ul>
<body>
</html>
""".format(*pluginPaths))
self.pluginCtrlMap = {
STATEMENT_WRITER:self.statementWriter,
REGISTRY_WRITER:self.registryWriter,
TRANSACTION_FORMATTER:self.transactionFormatter,
INIT_PARSER:self.initParser
}
self.app = wx.GetApp()
manager = PluginManagerSingleton.get()
for category, ctrl in self.pluginCtrlMap.items():
currentSel = self.app.getPluginNameFromConfig(category)
choices = [ p.name for p in
manager.getPluginsOfCategory(category) ]
ctrl.SetItems(choices)
try:
i = choices.index(currentSel)
ctrl.SetSelection(i)
except ValueError:
pass
开发者ID:miheerdew,项目名称:SalesMan,代码行数:35,代码来源:dialogs.py
示例19: activatedPlugins
def activatedPlugins():
"""
Activate and deactivate all the plugins.
"""
pm = PluginManagerSingleton.get()
activated = []
for pluginInfo in pm.getAllPlugins():
try:
pluginInfo.plugin_object.activate()
activated.append(pluginInfo)
log.debug('activated plugin %s', pluginInfo.name)
except:
log.error(('Exception activating plugin "%s". (Will not'
+ ' deactivate.)') % pluginInfo.name,
exc_info=True)
try:
yield activated
finally:
for pluginInfo in activated:
try:
pluginInfo.plugin_object.deactivate()
except:
log.error('Exception deactivating plugin "%s".'
% pluginInfo.name, exc_info=True)
开发者ID:bsparacino,项目名称:xbee-homeautomation,代码行数:25,代码来源:setuputil.py
示例20: __init__
def __init__(self, profile):
QtCore.QObject.__init__(self)
self.profile = profile
self.firstrun = False
self.plugmanc = PluginManagerSingleton.get()
locator = self.plugmanc.getPluginLocator()
locator.setPluginInfoExtension("freeseer-plugin")
# Get the path where the installed plugins are located on systems where
# freeseer is installed.
pluginpath = os.path.join(os.path.dirname(os.path.abspath(__file__)), os.pardir, "plugins")
self.plugmanc.setPluginPlaces([pluginpath, os.path.expanduser("~/.freeseer/plugins"), "freeseer/plugins"])
self.plugmanc.setCategoriesFilter(
{
"AudioInput": IAudioInput,
"AudioMixer": IAudioMixer,
"VideoInput": IVideoInput,
"VideoMixer": IVideoMixer,
"Importer": IImporter,
"Output": IOutput,
}
)
self.plugmanc.collectPlugins()
for plugin in self.plugmanc.getAllPlugins():
plugin.plugin_object.set_plugman(self)
log.debug("Plugin manager initialized.")
开发者ID:Promm,项目名称:freeseer,代码行数:31,代码来源:plugin.py
注:本文中的yapsy.PluginManager.PluginManagerSingleton类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论