本文整理汇总了Python中yapsy.PluginManager.PluginManager方法的典型用法代码示例。如果您正苦于以下问题:Python PluginManager.PluginManager方法的具体用法?Python PluginManager.PluginManager怎么用?Python PluginManager.PluginManager使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类yapsy.PluginManager
的用法示例。
在下文中一共展示了PluginManager.PluginManager方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from yapsy import PluginManager [as 别名]
# 或者: from yapsy.PluginManager import PluginManager [as 别名]
def __init__(self):
# Collect all the obfuscators contained in the ./obfuscators directory. Each
# obfuscator has an associated *.obfuscator file with some metadata and belongs
# to a category (see the base class of each obfuscator).
self.manager = PluginManager(
directories_list=[
os.path.join(os.path.dirname(os.path.realpath(__file__)), "obfuscators")
],
plugin_info_ext="obfuscator",
categories_filter={
"Trivial": obfuscator_category.ITrivialObfuscator,
"Rename": obfuscator_category.IRenameObfuscator,
"Encryption": obfuscator_category.IEncryptionObfuscator,
"Code": obfuscator_category.ICodeObfuscator,
"Resources": obfuscator_category.IResourcesObfuscator,
"Other": obfuscator_category.IOtherObfuscator,
},
)
self.manager.collectPlugins()
示例2: __init__
# 需要导入模块: from yapsy import PluginManager [as 别名]
# 或者: from yapsy.PluginManager import PluginManager [as 别名]
def __init__(self, decorated_object=None,
# The following args will only be used if we need to
# create a default PluginManager
categories_filter=None,
directories_list=None,
plugin_info_ext="yapsy-plugin"):
if directories_list is None:
directories_list = [os.path.dirname(__file__)]
if categories_filter is None:
categories_filter = {"Default": IPlugin}
if decorated_object is None:
log.debug("Creating a default PluginManager instance to be decorated.")
from yapsy.PluginManager import PluginManager
decorated_object = PluginManager(categories_filter,
directories_list,
plugin_info_ext)
self._component = decorated_object
示例3: init_request_validators
# 需要导入模块: from yapsy import PluginManager [as 别名]
# 或者: from yapsy.PluginManager import PluginManager [as 别名]
def init_request_validators(gn_env: GNEnvironment) -> None:
from yapsy.PluginManager import PluginManager
logging.getLogger('yapsy').setLevel(gn_env.config.get(ConfigKeys.LOG_LEVEL, logging.INFO))
plugin_manager = PluginManager()
plugin_manager.setPluginPlaces(['dino/validation/events'])
plugin_manager.collectPlugins()
for pluginInfo in plugin_manager.getAllPlugins():
plugin_manager.activatePluginByName(pluginInfo.name)
gn_env.event_validators[pluginInfo.name] = pluginInfo.plugin_object
validation = gn_env.config.get(ConfigKeys.VALIDATION, None)
if validation is None:
return
for key in validation.keys():
if key not in gn_env.event_validator_map:
gn_env.event_validator_map[key] = list()
plugins = validation[key].copy()
validation[key] = dict()
for plugin_info in plugins:
plugin_name = plugin_info.get('name')
validation[key][plugin_name] = plugin_info
try:
gn_env.event_validator_map[key].append(gn_env.event_validators[plugin_name])
except KeyError:
raise KeyError('specified plugin "%s" does not exist' % key)
gn_env.config.set(ConfigKeys.VALIDATION, validation)
for pluginInfo in plugin_manager.getAllPlugins():
pluginInfo.plugin_object.setup(gn_env)
示例4: getPluginsOfCategory
# 需要导入模块: from yapsy import PluginManager [as 别名]
# 或者: from yapsy.PluginManager import PluginManager [as 别名]
def getPluginsOfCategory(self, category_name):
"""
Plugin Managers compares the current list of plugins returned by Yapsy's PluginManager to the previous list
and reschedules if the two don't match. To guarantee that the list order is invariant in order to
prevent unnecessary re-scheduling, we sort plugins returned by PanoptesPluginManager.getPluginsOfCategory
by signature.
Args:
category_name (str): Plugin category
Returns:
list: Sorted list of plugins
"""
plugins_unfiltered = super(PanoptesPluginManager, self).getPluginsOfCategory(category_name)
return sorted(plugins_unfiltered, key=lambda obj: obj.signature)
示例5: get_plugins
# 需要导入模块: from yapsy import PluginManager [as 别名]
# 或者: from yapsy.PluginManager import PluginManager [as 别名]
def get_plugins(
category_filter={},
plugin_places=['plugins']):
pm = PluginManager(plugin_info_ext='plugin')
# Normalize the paths to the location of this file.
# XXX-ricarkol: there has to be a better way to do this.
plugin_places = [misc.execution_path(x) for x in plugin_places]
pm.setPluginPlaces(plugin_places)
pm.setCategoriesFilter(category_filter)
pm.collectPlugins()
return pm.getAllPlugins()
示例6: init_plugins
# 需要导入模块: from yapsy import PluginManager [as 别名]
# 或者: from yapsy.PluginManager import PluginManager [as 别名]
def init_plugins(self):
"""Inits plugins"""
self.manager = PluginManager()
self.manager.setPluginPlaces(["plugins"])
self.manager.collectPlugins()
for plugin in self.manager.getAllPlugins():
print_debug(f"Plugin found: {plugin.name}")
示例7: load_plugins
# 需要导入模块: from yapsy import PluginManager [as 别名]
# 或者: from yapsy.PluginManager import PluginManager [as 别名]
def load_plugins(cls):
manager = PluginManager()
manager.setPluginPlaces([os.path.join(os.getcwd(), "plugins/")])
manager.collectPlugins()
ret = manager.getAllPlugins()
logger.info('Loaded {} plugins'.format(len(ret)))
return ret
示例8: __init__
# 需要导入模块: from yapsy import PluginManager [as 别名]
# 或者: from yapsy.PluginManager import PluginManager [as 别名]
def __init__(self, es_hosts, es_index, es_mappings,
es_settings, plugin_paths, plugin_order,
data_config, es_config,
workers_write, queue_write):
self.es_hosts = es_hosts
self.es_index = es_index
self.es_mappings = es_mappings
self.es_settings = es_settings
self.plugin_order = plugin_order
self.data_config = data_config
self.es_config = es_config
self.workers_write = workers_write
self.queue_write = queue_write
self.genes = GeneSet()
self._logger = logging.getLogger(__name__)
self._logger.debug("Preparing the plug in management system")
# Build the manager
self.simplePluginManager = PluginManager()
# Tell it the default place(s) where to find plugins
self.simplePluginManager.setPluginPlaces(plugin_paths)
for dir in plugin_paths:
self._logger.debug("Looking for plugins in %s", dir)
# Load all plugins
self.simplePluginManager.collectPlugins()
示例9: get_manager
# 需要导入模块: from yapsy import PluginManager [as 别名]
# 或者: from yapsy.PluginManager import PluginManager [as 别名]
def get_manager():
"""Returns the PluginManager for this instance of WereSync"""
return __manager
示例10: run
# 需要导入模块: from yapsy import PluginManager [as 别名]
# 或者: from yapsy.PluginManager import PluginManager [as 别名]
def run(): # pragma: no cover
plugin_manager = PluginManager(
categories_filter={'py2swagger': Py2SwaggerPlugin},
directories_list=[os.path.join(os.path.dirname(__file__), 'plugins')],
plugin_info_ext='py2swagger'
)
plugin_manager.collectPlugins()
parser = argparse.ArgumentParser(description='Swagger schema builder')
parser.add_argument('-c', '--config', action='store', dest='config', help='Path to config file')
parser.add_argument('-r', '--root', action='store', dest='root', help='Path to project root. Default is current directory or configuration file location')
parser.add_argument('-o', '--output', action='store', dest='output', help='Output file (Default stdout)')
sub_parsers = parser.add_subparsers(title='plugins', dest='plugin')
# set arguments from plugins
for plugin in plugin_manager.getAllPlugins():
sub_parser = sub_parsers.add_parser(plugin.name,
help=plugin.plugin_object.summary,
description=plugin.plugin_object.description)
plugin.plugin_object.set_parser_arguments(sub_parser)
args = parser.parse_args()
sys.path.append(_get_project_root_path(args.root, args.config))
swagger_settings, plugin_settings = get_settings(args.config)
plugin = plugin_manager.getPluginByName(args.plugin, category='py2swagger')
if not plugin:
sys.stderr.write('Plugin not available\n')
sys.exit(1)
try:
swagger_settings_part = plugin.plugin_object.run(args, **plugin_settings)
except Py2SwaggerPluginException as e:
sys.stderr.write('{}\n'.format(e))
sys.exit(1)
swagger_settings = update_settings(swagger_settings, swagger_settings_part)
builder = SchemaBuilder(**swagger_settings)
swagger_schema = json.dumps(builder.schema, indent=2)
if args.output:
with codecs.open(args.output, 'wb', encoding='utf-8') as f:
f.write(swagger_schema)
else:
sys.stdout.write(swagger_schema)
示例11: __init__
# 需要导入模块: from yapsy import PluginManager [as 别名]
# 或者: from yapsy.PluginManager import PluginManager [as 别名]
def __init__(self, parent, plugin):
super(WUnpack, self).__init__(parent)
self.parent = parent
self.plugin = plugin
self.oshow = super(WUnpack, self).show
root = os.path.dirname(sys.argv[0])
self.ui = PyQt5.uic.loadUi(os.path.join(root, 'unpack.ui'), baseinstance=self)
self.ui.setWindowTitle('Decrypt/Encrypt')
self.manager = PluginManager(categories_filter={ "UnpackPlugin": DecryptPlugin})
root = os.path.dirname(sys.argv[0])
self.manager.setPluginPlaces([os.path.join(root, 'plugins', 'unpack')])
#self.manager.setPluginPlaces(["plugins"])
# Load plugins
self.manager.locatePlugins()
self.manager.loadPlugins()
self.Plugins = {}
Formats = []
for plugin in self.manager.getPluginsOfCategory("UnpackPlugin"):
# plugin.plugin_object is an instance of the plugin
po = plugin.plugin_object
if po.init(self.parent.dataModel, self.parent.viewMode):
self.Plugins[plugin.name] = po
#self.ui.horizontalLayout.addWidget(po.getUI())
print('[+] ' + plugin.name)
self.ui.listWidget.addItem(plugin.name)
#Formats.append(po)
self.ui.listWidget.currentItemChanged.connect(self.item_clicked)
self.ui.listWidget.setCurrentRow(0)
#self.ui.connect(self.ui.proceed, PyQt5.QtCore.SIGNAL("clicked()"), self.handleProceed)
self.ui.proceed.clicked.connect(lambda: self.handleProceed())
self.initUI()
示例12: load_plugins
# 需要导入模块: from yapsy import PluginManager [as 别名]
# 或者: from yapsy.PluginManager import PluginManager [as 别名]
def load_plugins(self):
print "Configuring Plugin manager."
self.plugins = PluginManager()
if self.MinionFolder is None:
self.plugins.setPluginPlaces([self.PluginFolder])
else:
self.plugins.setPluginPlaces([self.PluginFolder, self.MinionFolder])
#self.plugins.collectPlugins()
self.plugins.locatePlugins()
self.plugins.loadPlugins()
print "Plugin manager configured."
# Loop round the plugins and print their names.
cur = self.db.cursor()
# Clear tables
cur.execute("""DELETE FROM enrichments""")
cur.execute("""DELETE FROM inputs""")
cur.execute("""DELETE FROM storage""")
cur.execute("""DELETE FROM score""")
cur.execute("""DELETE FROM minion""")
for plugin in self.plugins.getAllPlugins():
plugin_config = plugin.plugin_object.configure()
# Insert enrichment
if plugin_config[0] == 'enrichment': # type
cur.execute('''INSERT INTO enrichments VALUES (?, ?, ?, ?, ?)''', (plugin_config[2], # Name
int(plugin_config[1]), # Enabled
plugin_config[3], # Descripton
plugin_config[5], # Cost
plugin_config[6]) # Speed
)
for inp in plugin_config[4]: # inputs
# Insert into inputs table
cur.execute('''INSERT INTO inputs VALUES (?,?)''', (plugin_config[2], inp))
self.db.commit()
elif plugin_config[0] == 'interface': # type
cur.execute('''INSERT INTO storage VALUES (?, ?)''', (plugin_config[2], int(plugin_config[1])))
elif plugin_config[0] == 'score':
cur.execute('''INSERT INTO score VALUES (?, ?, ?, ?, ?)''', (plugin_config[2], # Name
int(plugin_config[1]), # Enabled
plugin_config[3], # Descripton
plugin_config[4], # Cost
plugin_config[5]) # Speed
)
if plugin_config[0] == 'minion':
plugin_config = plugin.plugin_object.configure(self)
cur.execute('''INSERT INTO minion VALUES (?, ?, ?, ?)''', (plugin_config[2], # Name
int(plugin_config[1]), # Enabled
plugin_config[3], # Descripton
plugin_config[4]) # Speed
)
if plugin.name == "classify": # Classify is a unique name. TODO: figure out if handling multiple 'classify' plugins is necessary
self.classify = plugin.plugin_object
print "Configured {2} plugin {0}. Success: {1}".format(plugin.name, plugin_config[1], plugin_config[0])
示例13: load_plugins
# 需要导入模块: from yapsy import PluginManager [as 别名]
# 或者: from yapsy.PluginManager import PluginManager [as 别名]
def load_plugins():
"""Load plugins.
I/P Parameters
==============
None.
Actions
=======
1. Sets yapsy logger's logging level to the global default.
2. Loads the (one and only) plugin from the plugin directory.
3. Invokes the plugin's "print_name" method to print the name.
Return Value
============
Returns None.
"""
utils_logger.info('\n\nEntering load_plugins\n\n')
# Check if plugin function active
if not gbls.activate_plugins:
utils_logger.error(
'\n\n***Plugin function not active.'
'Plugin loading aborted.'
)
return None
# Set logging for the yapsy plugin framework
logging.getLogger('yapsy').setLevel(gbls.loglvl)
# Load the plugins from the plugin directory.
gbls.plugin_manager = PluginManager()
gbls.plugin_manager.setPluginPlaces([gbls.plugin_folder])
gbls.plugin_manager.collectPlugins()
# Loop through the plugins and print their names.
for plugin in gbls.plugin_manager.getAllPlugins():
plugin.plugin_object.print_name()
return None
示例14: __init__
# 需要导入模块: from yapsy import PluginManager [as 别名]
# 或者: from yapsy.PluginManager import PluginManager [as 别名]
def __init__(self):
self.ai = ai_interface.API(apiai.ApiAI(settings['CLIENT_ACCESS_TOKEN'],
settings['SUBSCRIPTION_KEY']))
self.debugging = settings['debugging']
self.spoken_language = settings['spoken language']
self.input_system = settings['input system'] # google, local, text
self.output_system = settings['output system'] # both, audio, text
self.speech_file_location = settings['speech file location'] # .
self.speech_file_name = settings['speech file name'] # audio response
self.speak = settings['speak'] # True
# The question that the assistant hears
self.question = None
# The chosen, spoken response given to the user.
self.response = None
# Whether Friday is active
self.is_active = True
# What type of question is being asked.
self.request_type = None
if settings['input system'] != 'text':
self.recognizer = sr.Recognizer()
self.microphone = sr.Microphone(device_index=settings['DEVICE'],
sample_rate=settings['RATE'],
chunk_size=settings['CHUNK'])
if settings['input_system'] == 'google':
with self.microphone as source:
if settings['debugging']:
click.echo("Adjusting to ambient noise.")
# we only need to calibrate once, before we start listening
self.recognizer.adjust_for_ambient_noise(source)
# Build the manager
self.manager = PluginManager()
# Tell it the default place(s) where to find plugins
self.manager.setPluginPlaces(settings["plugin folder"])
# Load all plugins
self.manager.locatePlugins()
self.manager.loadPlugins()
self.plugins = {}
# Activate all loaded plugins
for plugin in self.manager.getAllPlugins():
self.plugins[plugin.name] = plugin.plugin_object