本文整理汇总了Python中yapsy.PluginManager.PluginManagerSingleton.get方法的典型用法代码示例。如果您正苦于以下问题:Python PluginManagerSingleton.get方法的具体用法?Python PluginManagerSingleton.get怎么用?Python PluginManagerSingleton.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类yapsy.PluginManager.PluginManagerSingleton
的用法示例。
在下文中一共展示了PluginManagerSingleton.get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: deferred_botmsg
# 需要导入模块: from yapsy.PluginManager import PluginManagerSingleton [as 别名]
# 或者: from yapsy.PluginManager.PluginManagerSingleton import get [as 别名]
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.")
示例2: botmsg
# 需要导入模块: from yapsy.PluginManager import PluginManagerSingleton [as 别名]
# 或者: from yapsy.PluginManager.PluginManagerSingleton import get [as 别名]
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.")
示例3: botmsg
# 需要导入模块: from yapsy.PluginManager import PluginManagerSingleton [as 别名]
# 或者: from yapsy.PluginManager.PluginManagerSingleton import get [as 别名]
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.")
示例4: testActivationAndDeactivation
# 需要导入模块: from yapsy.PluginManager import PluginManagerSingleton [as 别名]
# 或者: from yapsy.PluginManager.PluginManagerSingleton import get [as 别名]
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)
示例5: plugin_activate
# 需要导入模块: from yapsy.PluginManager import PluginManagerSingleton [as 别名]
# 或者: from yapsy.PluginManager.PluginManagerSingleton import get [as 别名]
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)
示例6: user_joined
# 需要导入模块: from yapsy.PluginManager import PluginManagerSingleton [as 别名]
# 或者: from yapsy.PluginManager.PluginManagerSingleton import get [as 别名]
def user_joined(self, user, channel):
user = user.split("!")[0]
manager = PluginManagerSingleton.get()
_notes = manager.app.plugin_get_setting("notePlugin", "notes")
if user in _notes:
if len(_notes[user]) > 0:
manager.app.msg(user, "You have " + str(len(_notes[user])) + " new messages. Use !note read to read each one.")
示例7: _init_plugin_engine
# 需要导入模块: from yapsy.PluginManager import PluginManagerSingleton [as 别名]
# 或者: from yapsy.PluginManager.PluginManagerSingleton import get [as 别名]
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
示例8: load_state
# 需要导入模块: from yapsy.PluginManager import PluginManagerSingleton [as 别名]
# 或者: from yapsy.PluginManager.PluginManagerSingleton import get [as 别名]
def load_state(self, filename):
"""
get state of ui and all plugins from file, and set to the ui
"""
try:
with open(filename, "r") as f:
modelstring = f.read()
except IOError:
return
import json
model = json.loads(modelstring)
plugin_model = model['plugins']
del model['plugins']
self.serializer.model_to_ui(model)
from yapsy.PluginManager import PluginManagerSingleton
manager = PluginManagerSingleton.get()
for plugin in manager.getAllPlugins():
for section in SECTIONS:
self.suspend_plugin(plugin.plugin_object, section)
name = plugin.plugin_object.name
if name in plugin_model:
plugin.plugin_object.set_state_from_dict(self.MainWindow.centralWidget(),plugin_model[name])
self.attentionCheckBoxClicked()
self.meditationCheckBoxClicked()
self.eyeBlinkCheckBoxClicked()
示例9: privmsg
# 需要导入模块: from yapsy.PluginManager import PluginManagerSingleton [as 别名]
# 或者: from yapsy.PluginManager.PluginManagerSingleton import get [as 别名]
def privmsg(self, user, channel, msg):
manager = PluginManagerSingleton.get()
if str(msg).startswith('_pypi'):
pkg = msg[len('_pypi'):].strip()
print('Looking up PyPi package %s' % pkg)
try:
resp = urlopen('https://pypi.python.org/pypi/%s' % pkg)
except HTTPError:
manager.app.say(channel, 'Silly %s, this package doesn\'t exist!' % user)
return
html = resp.read()
soup = BeautifulSoup(html)
section = soup.find('div', {'class': 'section'})
if 'Index' in section.find('h1').contents[0]:
latest = section.find('table').find('a').contents[0].lower() \
.replace(pkg.lower(), '').encode('ascii', 'ignore')
all_versions = section.find('table').find_all('a')
versions = ''
version_count = 0
for version in all_versions:
separator = ', ' if version_count != 0 else ''
versions += '%s%s' % (separator, version.contents[0].lower().replace(pkg.lower(), ''))
version_count += 1
if 10 == version_count:
break
versions = versions.encode('ascii', 'ignore')
manager.app.say(channel, 'Please specify a version. Latest: %s' % str(latest))
manager.app.say(channel, 'Available versions: %s' % str(versions))
return
version = section.find('h1').contents[0]
description = section.find('p').contents[0]
manager.app.say(channel, 'Package: %s' % str(version).strip())
manager.app.say(channel, 'Description: %s' % str(description).strip())
manager.app.say(channel, 'URL: %s' % ('https://pypi.python.org/pypi/%s' % pkg))
示例10: list
# 需要导入模块: from yapsy.PluginManager import PluginManagerSingleton [as 别名]
# 或者: from yapsy.PluginManager.PluginManagerSingleton import get [as 别名]
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)
示例11: _load_filesystem_plugins
# 需要导入模块: from yapsy.PluginManager import PluginManagerSingleton [as 别名]
# 或者: from yapsy.PluginManager.PluginManagerSingleton import get [as 别名]
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)
示例12: activatedPlugins
# 需要导入模块: from yapsy.PluginManager import PluginManagerSingleton [as 别名]
# 或者: from yapsy.PluginManager.PluginManagerSingleton import get [as 别名]
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)
示例13: __init__
# 需要导入模块: from yapsy.PluginManager import PluginManagerSingleton [as 别名]
# 或者: from yapsy.PluginManager.PluginManagerSingleton import get [as 别名]
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)
示例14: __init__
# 需要导入模块: from yapsy.PluginManager import PluginManagerSingleton [as 别名]
# 或者: from yapsy.PluginManager.PluginManagerSingleton import get [as 别名]
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
示例15: create_plugin_config
# 需要导入模块: from yapsy.PluginManager import PluginManagerSingleton [as 别名]
# 或者: from yapsy.PluginManager.PluginManagerSingleton import get [as 别名]
def create_plugin_config(self):
# get current directory and plugin directory
current_dir = path.abspath(path.dirname(__file__))
plugin_dir = path.join(current_dir, 'plugins')
# configure plugin manager
manager = PluginManagerSingleton.get()
manager.setPluginPlaces([plugin_dir])
manager.collectPlugins()
# set default value for plugin key
self.config.get('plugins', {})
# iterate over all plugins
for plugin in manager.getAllPlugins():
manager.activatePluginByName(plugin.name)
# get the default config if the plugin if available
if hasattr(plugin.plugin_object, 'default_config'):
# create the default config if not already in the config
if plugin.name.strip().lower() not in self.config['plugins']:
self.config['plugins'][plugin.name.strip().lower()] = plugin.plugin_object.default_config
else:
# update keys
for k, v in plugin.plugin_object.default_config.items():
if k not in self.config['plugins'][plugin.name.strip().lower()]:
self.config['plugins'][plugin.name.strip().lower()][k] = v
# reset plugin manager
PluginManagerSingleton._PluginManagerSingleton__instance = None
self.update_config()
print('Updated default plugin config at ./config.json')