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


Python extension.ExtensionManager方法代码示例

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


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

示例1: _load_hooks

# 需要导入模块: from stevedore import extension [as 别名]
# 或者: from stevedore.extension import ExtensionManager [as 别名]
def _load_hooks(self):
        # Look for command extensions
        if self.app and self.cmd_name:
            namespace = '{}.{}'.format(
                self.app.command_manager.namespace,
                self.cmd_name.replace(' ', '_')
            )
            self._hooks = extension.ExtensionManager(
                namespace=namespace,
                invoke_on_load=True,
                invoke_kwds={
                    'command': self,
                },
            )
        else:
            # Setting _hooks to an empty list allows iteration without
            # checking if there are hooks every time.
            self._hooks = []
        return 
开发者ID:openstack,项目名称:cliff,代码行数:21,代码来源:command.py

示例2: _list_opts

# 需要导入模块: from stevedore import extension [as 别名]
# 或者: from stevedore.extension import ExtensionManager [as 别名]
def _list_opts():
    driver_opts = []
    mgr = extension.ExtensionManager('glance_store.drivers')
    # NOTE(zhiyan): Handle available drivers entry_points provided
    # NOTE(nikhil): Return a sorted list of drivers to ensure that the sample
    # configuration files generated by oslo config generator retain the order
    # in which the config opts appear across different runs. If this order of
    # config opts is not preserved, some downstream packagers may see a long
    # diff of the changes though not relevant as only order has changed. See
    # some more details at bug 1619487.
    drivers = sorted([ext.name for ext in mgr])
    handled_drivers = []  # Used to handle backwards-compatible entries
    for store_entry in drivers:
        driver_cls = _load_store(None, store_entry, False)
        if driver_cls and driver_cls not in handled_drivers:
            if getattr(driver_cls, 'OPTIONS', None) is not None:
                driver_opts += driver_cls.OPTIONS
            handled_drivers.append(driver_cls)

    # NOTE(zhiyan): This separated approach could list
    # store options before all driver ones, which easier
    # to read and configure by operator.
    return ([(_STORE_CFG_GROUP, _STORE_OPTS)] +
            [(_STORE_CFG_GROUP, driver_opts)]) 
开发者ID:openstack,项目名称:glance_store,代码行数:26,代码来源:backend.py

示例3: _list_driver_opts

# 需要导入模块: from stevedore import extension [as 别名]
# 或者: from stevedore.extension import ExtensionManager [as 别名]
def _list_driver_opts():
    driver_opts = {}
    mgr = extension.ExtensionManager('glance_store.drivers')
    # NOTE(zhiyan): Handle available drivers entry_points provided
    # NOTE(nikhil): Return a sorted list of drivers to ensure that the sample
    # configuration files generated by oslo config generator retain the order
    # in which the config opts appear across different runs. If this order of
    # config opts is not preserved, some downstream packagers may see a long
    # diff of the changes though not relevant as only order has changed. See
    # some more details at bug 1619487.
    drivers = sorted([ext.name for ext in mgr])
    handled_drivers = []  # Used to handle backwards-compatible entries
    for store_entry in drivers:
        driver_cls = _load_multi_store(None, store_entry, False)
        if driver_cls and driver_cls not in handled_drivers:
            if getattr(driver_cls, 'OPTIONS', None) is not None:
                driver_opts[store_entry] = driver_cls.OPTIONS
            handled_drivers.append(driver_cls)

    # NOTE(zhiyan): This separated approach could list
    # store options before all driver ones, which easier
    # to read and configure by operator.
    return driver_opts 
开发者ID:openstack,项目名称:glance_store,代码行数:25,代码来源:multi_backend.py

示例4: load_namespace

# 需要导入模块: from stevedore import extension [as 别名]
# 或者: from stevedore.extension import ExtensionManager [as 别名]
def load_namespace(self, ns):
        """Load commands from namespace.

        :param ns: namespace name
        :type ns: str
        """
        mgr = extension.ExtensionManager(namespace=ns,
                                         verify_requirements=True,
                                         on_load_failure_callback=self._on_failure)
        # Load commands from ns
        for ext in mgr.extensions:
            try:
                obj = ext.plugin(ext.name)
            except Exception as err:
                self._on_failure(self, ext, err)
                obj = None
            ext.obj = obj

        self.mgrs.append(mgr) 
开发者ID:eonpatapon,项目名称:contrail-api-cli,代码行数:21,代码来源:manager.py

示例5: load_plugins

# 需要导入模块: from stevedore import extension [as 别名]
# 或者: from stevedore.extension import ExtensionManager [as 别名]
def load_plugins(self, plugins_namespace):
        self.plugins_mgr = extension.ExtensionManager(
            namespace=plugins_namespace,
            invoke_on_load=False,
            verify_requirements=False,
            )

        def test_has_id(plugin):
            if not hasattr(plugin.plugin, "_test_id"):
                # logger not setup yet, so using print
                print("WARNING: Test '%s' has no ID, skipping." % plugin.name,
                      file=sys.stderr)
                return False
            return True

        self.plugins = list(filter(test_has_id, list(self.plugins_mgr)))
        self.plugin_names = [plugin.name for plugin in self.plugins]
        self.plugins_by_id = {p.plugin._test_id: p for p in self.plugins}
        self.plugins_by_name = {p.name: p for p in self.plugins} 
开发者ID:PyCQA,项目名称:bandit,代码行数:21,代码来源:extension_loader.py

示例6: load_blacklists

# 需要导入模块: from stevedore import extension [as 别名]
# 或者: from stevedore.extension import ExtensionManager [as 别名]
def load_blacklists(self, blacklist_namespace):
        self.blacklists_mgr = extension.ExtensionManager(
            namespace=blacklist_namespace,
            invoke_on_load=False,
            verify_requirements=False,
            )
        self.blacklist = {}
        blacklist = list(self.blacklists_mgr)
        for item in blacklist:
            for key, val in item.plugin().items():
                utils.check_ast_node(key)
                self.blacklist.setdefault(key, []).extend(val)

        self.blacklist_by_id = {}
        self.blacklist_by_name = {}
        for val in six.itervalues(self.blacklist):
            for b in val:
                self.blacklist_by_id[b['id']] = b
                self.blacklist_by_name[b['name']] = b 
开发者ID:PyCQA,项目名称:bandit,代码行数:21,代码来源:extension_loader.py

示例7: test_extension_failure_custom_callback

# 需要导入模块: from stevedore import extension [as 别名]
# 或者: from stevedore.extension import ExtensionManager [as 别名]
def test_extension_failure_custom_callback(self):
        errors = []

        def failure_callback(manager, entrypoint, error):
            errors.append((manager, entrypoint, error))

        em = extension.ExtensionManager('stevedore.test.extension',
                                        invoke_on_load=True,
                                        on_load_failure_callback=
                                        failure_callback)
        extensions = list(em.extensions)
        self.assertTrue(len(extensions), GreaterThan(0))
        self.assertEqual(len(errors), 2)
        for manager, entrypoint, error in errors:
            self.assertIs(manager, em)
            self.assertIsInstance(error, (IOError, ImportError)) 
开发者ID:openstack,项目名称:stevedore,代码行数:18,代码来源:test_callback.py

示例8: test_map_arguments

# 需要导入模块: from stevedore import extension [as 别名]
# 或者: from stevedore.extension import ExtensionManager [as 别名]
def test_map_arguments(self):
        objs = []

        def mapped(ext, *args, **kwds):
            objs.append((ext, args, kwds))

        em = extension.ExtensionManager('stevedore.test.extension',
                                        invoke_on_load=True,
                                        )
        em.map(mapped, 1, 2, a='A', b='B')
        self.assertEqual(len(objs), 2)
        names = sorted([o[0].name for o in objs])
        self.assertEqual(names, WORKING_NAMES)
        for o in objs:
            self.assertEqual(o[1], (1, 2))
            self.assertEqual(o[2], {'a': 'A', 'b': 'B'}) 
开发者ID:openstack,项目名称:stevedore,代码行数:18,代码来源:test_extension.py

示例9: ready

# 需要导入模块: from stevedore import extension [as 别名]
# 或者: from stevedore.extension import ExtensionManager [as 别名]
def ready(self):
        """
        Loads the available proctoring backends
        """
        from edx_proctoring import signals  # pylint: disable=unused-import
        config = settings.PROCTORING_BACKENDS

        self.backends = {}  # pylint: disable=W0201
        for extension in ExtensionManager(namespace='openedx.proctoring'):
            name = extension.name
            try:
                options = config[name]
                self.backends[name] = extension.plugin(**options)
            except KeyError:
                pass
        make_worker_config(list(self.backends.values()), out=os.path.join(settings.ENV_ROOT, 'workers.json')) 
开发者ID:edx,项目名称:edx-proctoring,代码行数:18,代码来源:apps.py

示例10: fetch_checks

# 需要导入模块: from stevedore import extension [as 别名]
# 或者: from stevedore.extension import ExtensionManager [as 别名]
def fetch_checks(cfg):
    base = [
        checks.CheckValidity(cfg),
        checks.CheckTrailingWhitespace(cfg),
        checks.CheckIndentationNoTab(cfg),
        checks.CheckCarriageReturn(cfg),
        checks.CheckMaxLineLength(cfg),
        checks.CheckNewlineEndOfFile(cfg),
    ]
    mgr = extension.ExtensionManager(
        namespace="doc8.extension.check", invoke_on_load=True, invoke_args=(cfg.copy(),)
    )
    addons = []
    for e in mgr:
        addons.append(e.obj)
    return base + addons 
开发者ID:PyCQA,项目名称:doc8,代码行数:18,代码来源:main.py

示例11: test_extensions_config

# 需要导入模块: from stevedore import extension [as 别名]
# 或者: from stevedore.extension import ExtensionManager [as 别名]
def test_extensions_config(self):
        """
        Test if the edx.analytics.tasks entry_points are configured properly.

        Note that extensions are only defined after the package
        `edx.analytics.tasks` has been installed.

        """

        manager = ExtensionManager(
            namespace=EXTENSION_NAMESPACE,
            on_load_failure_callback=self.on_load_failure,
            verify_requirements=True
        )

        if len(manager.extensions) == 0:
            reason = 'no entry_points for {0} namespace'
            raise unittest.SkipTest(reason.format(EXTENSION_NAMESPACE)) 
开发者ID:edx,项目名称:edx-analytics-pipeline,代码行数:20,代码来源:test_extensions.py

示例12: register_runners

# 需要导入模块: from stevedore import extension [as 别名]
# 或者: from stevedore.extension import ExtensionManager [as 别名]
def register_runners(experimental=False, fail_on_failure=True):
    """
    Register runners
    """
    LOG.debug('Start : register runners')
    runner_count = 0

    manager = ExtensionManager(namespace=RUNNERS_NAMESPACE, invoke_on_load=False)
    extension_names = manager.names()

    for name in extension_names:
        LOG.debug('Found runner "%s"' % (name))

        manager = DriverManager(namespace=RUNNERS_NAMESPACE, invoke_on_load=False, name=name)
        runner_metadata = manager.driver.get_metadata()
        runner_count += register_runner(runner_metadata, experimental)

    LOG.debug('End : register runners')

    return runner_count 
开发者ID:StackStorm,项目名称:st2,代码行数:22,代码来源:runnersregistrar.py

示例13: _initialize_drivers

# 需要导入模块: from stevedore import extension [as 别名]
# 或者: from stevedore.extension import ExtensionManager [as 别名]
def _initialize_drivers(self, enabled_drivers=None):
        """Load accelerator drivers.

        :return: [nvidia_gpu_driver_obj, intel_fpga_driver_obj]
        """
        acc_drivers = []
        if not enabled_drivers:
            enabled_drivers = CONF.agent.enabled_drivers
        valid_drivers = ExtensionManager(
            namespace='cyborg.accelerator.driver').names()
        for d in enabled_drivers:
            if d not in valid_drivers:
                raise exception.InvalidDriver(name=d)
            acc_driver = driver.DriverManager(
                namespace='cyborg.accelerator.driver', name=d,
                invoke_on_load=True).driver
            acc_drivers.append(acc_driver)
        self.acc_drivers = acc_drivers 
开发者ID:openstack,项目名称:cyborg,代码行数:20,代码来源:resource_tracker.py

示例14: test_extension_failure_custom_callback

# 需要导入模块: from stevedore import extension [as 别名]
# 或者: from stevedore.extension import ExtensionManager [as 别名]
def test_extension_failure_custom_callback(self):
        errors = []

        def failure_callback(manager, entrypoint, error):
            errors.append((manager, entrypoint, error))

        em = extension.ExtensionManager('stevedore.test.extension',
                                        invoke_on_load=True,
                                        on_load_failure_callback=
                                        failure_callback)
        extensions = list(em.extensions)
        self.assertThat(len(extensions), GreaterThan(0))
        self.assertEqual(len(errors), 2)
        for manager, entrypoint, error in errors:
            self.assertIs(manager, em)
            self.assertIsInstance(error, (IOError, ImportError)) 
开发者ID:morpheus65535,项目名称:bazarr,代码行数:18,代码来源:test_callback.py

示例15: get_available_commands

# 需要导入模块: from stevedore import extension [as 别名]
# 或者: from stevedore.extension import ExtensionManager [as 别名]
def get_available_commands():
    em = ExtensionManager('designate.manage')
    return dict([(e.name, e.plugin) for e in em.extensions]) 
开发者ID:openstack,项目名称:designate,代码行数:5,代码来源:manage.py


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