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


Python service.IServiceMaker方法代码示例

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


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

示例1: makeService

# 需要导入模块: from twisted.application import service [as 别名]
# 或者: from twisted.application.service import IServiceMaker [as 别名]
def makeService(self, options):
        """Override IServiceMaker.makeService."""
        factory = bashplex.DelimitedBashReceiverFactory()
        factory.ping_interval = int(options['ping-interval'])
        factory.ping_timeout = int(options['ping-timeout'])
        factory.startup_commands = filter_bash(
            '/usr/share/epoptes/client-functions')

        if config.system['ENCRYPTION']:
            client_service = internet.SSLServer(
                int(config.system['PORT']), factory, ServerContextFactory())
        else:
            client_service = internet.TCPServer(
                int(config.system['PORT']), factory)

        gid = grp.getgrnam(config.system['SOCKET_GROUP'])[2]

        if not os.path.isdir(config.system['DIR']):
            # TODO: for some reason this does 0750 instead
            os.makedirs(config.system['DIR'], 0o2770)
        os.chmod(config.system['DIR'], 0o2770)
        os.chown(config.system['DIR'], -1, gid)

        gui_service = internet.UNIXServer(
            "%s/epoptes.socket" % config.system['DIR'],
            guiplex.GUIFactory())

        top_service = service.MultiService()
        top_service.addService(client_service)
        top_service.addService(gui_service)

        return top_service 
开发者ID:epoptes,项目名称:epoptes,代码行数:34,代码来源:epoptesd.py

示例2: createOrGetApplication

# 需要导入模块: from twisted.application import service [as 别名]
# 或者: from twisted.application.service import IServiceMaker [as 别名]
def createOrGetApplication(self):
        """
        Create or load an Application based on the parameters found in the
        given L{ServerOptions} instance.

        If a subcommand was used, the L{service.IServiceMaker} that it
        represents will be used to construct a service to be added to
        a newly-created Application.

        Otherwise, an application will be loaded based on parameters in
        the config.
        """
        if self.config.subCommand:
            # If a subcommand was given, it's our responsibility to create
            # the application, instead of load it from a file.

            # loadedPlugins is set up by the ServerOptions.subCommands
            # property, which is iterated somewhere in the bowels of
            # usage.Options.
            plg = self.config.loadedPlugins[self.config.subCommand]
            ser = plg.makeService(self.config.subOptions)
            application = service.Application(plg.tapname)
            ser.setServiceParent(application)
        else:
            passphrase = getPassphrase(self.config['encrypted'])
            application = getApplication(self.config, passphrase)
        return application 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:29,代码来源:app.py

示例3: subCommands

# 需要导入模块: from twisted.application import service [as 别名]
# 或者: from twisted.application.service import IServiceMaker [as 别名]
def subCommands(self):
        plugins = self._getPlugins(service.IServiceMaker)
        self.loadedPlugins = {}
        for plug in sorted(plugins, key=attrgetter('tapname')):
            self.loadedPlugins[plug.tapname] = plug
            yield (plug.tapname,
                   None,
                   # Avoid resolving the options attribute right away, in case
                   # it's a property with a non-trivial getter (eg, one which
                   # imports modules).
                   lambda plug=plug: plug.options(),
                   plug.description) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:14,代码来源:app.py

示例4: test_subCommands

# 需要导入模块: from twisted.application import service [as 别名]
# 或者: from twisted.application.service import IServiceMaker [as 别名]
def test_subCommands(self):
        """
        subCommands is built from IServiceMaker plugins, and is sorted
        alphabetically.
        """
        class FakePlugin(object):
            def __init__(self, name):
                self.tapname = name
                self._options = 'options for ' + name
                self.description = 'description of ' + name

            def options(self):
                return self._options

        apple = FakePlugin('apple')
        banana = FakePlugin('banana')
        coconut = FakePlugin('coconut')
        donut = FakePlugin('donut')

        def getPlugins(interface):
            self.assertEqual(interface, IServiceMaker)
            yield coconut
            yield banana
            yield donut
            yield apple

        config = twistd.ServerOptions()
        self.assertEqual(config._getPlugins, plugin.getPlugins)
        config._getPlugins = getPlugins

        # "subCommands is a list of 4-tuples of (command name, command
        # shortcut, parser class, documentation)."
        subCommands = config.subCommands
        expectedOrder = [apple, banana, coconut, donut]

        for subCommand, expectedCommand in zip(subCommands, expectedOrder):
            name, shortcut, parserClass, documentation = subCommand
            self.assertEqual(name, expectedCommand.tapname)
            self.assertIsNone(shortcut)
            self.assertEqual(parserClass(), expectedCommand._options),
            self.assertEqual(documentation, expectedCommand.description) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:43,代码来源:test_twistd.py

示例5: __init__

# 需要导入模块: from twisted.application import service [as 别名]
# 或者: from twisted.application.service import IServiceMaker [as 别名]
def __init__(self, className, *args, **kwargs):
        """
        @param className: The fully qualified name of the
            L{IServiceMaker}-providing class to instantiate.
        @type className: L{str}

        @param args: Sequential arguments to pass to the class's constructor.
        @type args: arguments L{list}

        @param kwargs: Keyword arguments to pass to the class's constructor.
        @type args: arguments L{dict}
        """
        self.className = className
        self.args = args
        self.kwargs = kwargs 
开发者ID:apple,项目名称:ccs-twistedextensions,代码行数:17,代码来源:masterchild.py

示例6: subCommands

# 需要导入模块: from twisted.application import service [as 别名]
# 或者: from twisted.application.service import IServiceMaker [as 别名]
def subCommands(self):
        from twisted import plugin
        plugins = plugin.getPlugins(service.IServiceMaker)
        self.loadedPlugins = {}
        for plug in plugins:
            self.loadedPlugins[plug.tapname] = plug
            yield (plug.tapname, None, lambda: plug.options(), plug.description) 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:9,代码来源:app.py

示例7: loadPlugins

# 需要导入模块: from twisted.application import service [as 别名]
# 或者: from twisted.application.service import IServiceMaker [as 别名]
def loadPlugins(debug = None, progress = None):
    tapLookup = {}

    plugins = plugin.getPlugins(IServiceMaker)
    for plug in plugins:
        tapLookup[plug.tapname] = plug

    return tapLookup 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:10,代码来源:mktap.py

示例8: init

# 需要导入模块: from twisted.application import service [as 别名]
# 或者: from twisted.application.service import IServiceMaker [as 别名]
def init(self, tapLookup):
        sc = []
        for (name, module) in tapLookup.iteritems():
            if IServiceMaker.providedBy(module):
                sc.append((
                    name, None, lambda m=module: m.options(), module.description))
            else:
                sc.append((
                    name, None, lambda obj=module: obj.load().Options(),
                    getattr(module, 'description', '')))

        sc.sort()
        self.subCommands = sc 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:15,代码来源:mktap.py


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