示例#1
0
文件: xml.py 项目: rockyburt/Rezine
    def _dispatch(self, method, args):
        """Dispatches the XML-RPC method.

        XML-RPC calls are forwarded to a registered function that
        matches the called XML-RPC method name. If no such function
        exists then the call is forwarded to the registered instance,
        if available.
        """
        func = self.funcs.get(method)
        if func is None:
            log.info('Client tried to access missing XMLRPC method %r on '
                     'XMLRPC dispatcher "%s"' % (method, self.name), 'xmlrpc')
            raise xmlrpclib.Fault(1, 'method "%s" is not supported' % method)
        return func(*args)
示例#2
0
文件: xml.py 项目: rockyburt/Rezine
    def _dispatch(self, method, args):
        """Dispatches the XML-RPC method.

        XML-RPC calls are forwarded to a registered function that
        matches the called XML-RPC method name. If no such function
        exists then the call is forwarded to the registered instance,
        if available.
        """
        func = self.funcs.get(method)
        if func is None:
            log.info(
                "Client tried to access missing XMLRPC method %r on " 'XMLRPC dispatcher "%s"' % (method, self.name),
                "xmlrpc",
            )
            raise xmlrpclib.Fault(1, 'method "%s" is not supported' % method)
        return func(*args)
示例#3
0
def find_plugins(app):
    """Return an iterator over all plugins available."""
    enabled_plugins = set()
    found_plugins = set()
    plugins = []
    for plugin in app.cfg['plugins']:
        plugin = plugin.strip()
        if plugin:
            enabled_plugins.add(plugin)

    for folder in app.plugin_searchpath:
        if not path.isdir(folder):
            continue
        for filename in listdir(folder):
            full_name = path.join(folder, filename)
            if (filename not in found_plugins and
                path.isdir(full_name) and
                path.isfile(path.join(full_name, 'metadata.txt'))):
                found_plugins.add(filename)
                plugins.append(FilesystemPlugin(app, str(filename),
                                                path.abspath(full_name),
                                                filename in enabled_plugins))
                log.info('added filesystem plugin "%s" - %s'
                         % (filename, full_name))

    for ep in pkg_resources.iter_entry_points('rezine_plugins'):
        if ep.name not in found_plugins:
            found_plugins.add(ep.name)
            plugins.append(EntryPointPlugin(app, ep,
                                            ep.name in enabled_plugins))
            log.info('added entry point plugin "%s" - %s'
                     % (ep.name, str(ep)))
        else:
            log.info('skipped entry point plugin "%s" - %s'
                     % (ep.name, str(ep)))

    return sorted(plugins)
示例#4
0
def find_plugins(app):
    """Return an iterator over all plugins available."""
    enabled_plugins = set()
    found_plugins = set()
    plugins = []
    for plugin in app.cfg['plugins']:
        plugin = plugin.strip()
        if plugin:
            enabled_plugins.add(plugin)

    for folder in app.plugin_searchpath:
        if not path.isdir(folder):
            continue
        for filename in listdir(folder):
            full_name = path.join(folder, filename)
            if (filename not in found_plugins and path.isdir(full_name)
                    and path.isfile(path.join(full_name, 'metadata.txt'))):
                found_plugins.add(filename)
                plugins.append(
                    FilesystemPlugin(app, str(filename),
                                     path.abspath(full_name), filename
                                     in enabled_plugins))
                log.info('added filesystem plugin "%s" - %s' %
                         (filename, full_name))

    for ep in pkg_resources.iter_entry_points('rezine_plugins'):
        if ep.name not in found_plugins:
            found_plugins.add(ep.name)
            plugins.append(
                EntryPointPlugin(app, ep, ep.name in enabled_plugins))
            log.info('added entry point plugin "%s" - %s' % (ep.name, str(ep)))
        else:
            log.info('skipped entry point plugin "%s" - %s' %
                     (ep.name, str(ep)))

    return sorted(plugins)