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


Python MultiService.setServiceParent方法代码示例

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


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

示例1: setServiceParent

# 需要导入模块: from twisted.application.service import MultiService [as 别名]
# 或者: from twisted.application.service.MultiService import setServiceParent [as 别名]
    def setServiceParent(self, parent):
        MultiService.setServiceParent(self, parent)

        self.pb = PbService(self.config.socket)
        self.pb.setServiceParent(self)

        self.resolver = Resolver(self.config.resolver_cache)
        self.resolver.setServiceParent(self)

        self.proxyservices = []
        for service in self.config.services:
            p = ProxyService(service)
            p.setServiceParent(self)
            self.proxyservices.append(p)
开发者ID:isotoma,项目名称:badgerproxy,代码行数:16,代码来源:badgerproxy.py

示例2: setServiceParent

# 需要导入模块: from twisted.application.service import MultiService [as 别名]
# 或者: from twisted.application.service.MultiService import setServiceParent [as 别名]
    def setServiceParent(self, app):
        MultiService.setServiceParent(self, app)

        if config.ErrorLogEnabled:
            errorLogFile = LogFile.fromFullPath(
                config.ErrorLogFile,
                rotateLength=config.ErrorLogRotateMB * 1024 * 1024,
                maxRotatedFiles=config.ErrorLogMaxRotatedFiles
            )
            errorLogObserver = FileLogObserver(errorLogFile).emit

            # Registering ILogObserver with the Application object
            # gets our observer picked up within AppLogger.start( )
            app.setComponent(ILogObserver, errorLogObserver)
开发者ID:svn2github,项目名称:calendarserver-raw,代码行数:16,代码来源:caldav.py

示例3: add

# 需要导入模块: from twisted.application.service import MultiService [as 别名]
# 或者: from twisted.application.service.MultiService import setServiceParent [as 别名]
    def add(self, name, services):
        log.msg(
            'bit.core.services: Services.add %s, %s' % (name, services))
        if not isinstance(services, dict):
            services.setName(name)
            services.setServiceParent(self.collect)
            self._services.append(name)
            return

        add = True
        if name in self._multi:
            plug_services = self.collect.getServiceNamed(name)
            add = False
        else:
            plug_services = MultiService()
            plug_services.setName(name)
            self._multi.append(name)
        for sid, s in services.items():
            s.setName(sid)
            s.setServiceParent(plug_services)
        if add:
            plug_services.setServiceParent(self.collect)
开发者ID:bithub,项目名称:bit.core,代码行数:24,代码来源:services.py

示例4: MHubApp

# 需要导入模块: from twisted.application.service import MultiService [as 别名]
# 或者: from twisted.application.service.MultiService import setServiceParent [as 别名]
class MHubApp(object):

    """
    Core application container responsible for managing and running of configured plugins.

    :param cfg: Application configuration dictionary
    :type cfg: dict.
    """



    def __init__(self, cfg=None):

        """
        Constructor
        """

        self.cfg = cfg or dict()
        self.logger = logging.getLogger("app")

        self.reactor = reactor
        self.root_service = MultiService()
        self.service = MHubService(self.cfg, self.reactor, self)
        self.application = Application("mhub")
        self.root_service.setServiceParent(self.application)


    def get_application(self):

        """
        Get the Twisted application object.

        :returns: Application
        """

        return self.application
开发者ID:jinglemansweep,项目名称:MHub,代码行数:38,代码来源:app.py

示例5: setServiceParent

# 需要导入模块: from twisted.application.service import MultiService [as 别名]
# 或者: from twisted.application.service.MultiService import setServiceParent [as 别名]
 def setServiceParent(self, parent):
   MultiService.setServiceParent(self, parent)
   if isinstance(parent, Componentized):
     parent.setComponent(ILogObserver, carbonLogObserver)
开发者ID:laiwei,项目名称:carbon,代码行数:6,代码来源:service.py

示例6: MultiService

# 需要导入模块: from twisted.application.service import MultiService [as 别名]
# 或者: from twisted.application.service.MultiService import setServiceParent [as 别名]
from twisted.application.internet import TCPClient, TCPServer
from twisted.application.service import Application, MultiService

from bravo.amp import ConsoleRPCFactory
from bravo.config import configuration
from bravo.factory import BetaFactory
from bravo.irc import BravoIRC

service = MultiService()

worlds = []
for section in configuration.sections():
    if section.startswith("world "):
        factory = BetaFactory(section[6:])
        TCPServer(factory.port, factory).setServiceParent(service)
        worlds.append(factory)
    elif section.startswith("irc "):
        factory = BravoIRC(worlds, section[4:])
        TCPClient(factory.host, factory.port,
            factory).setServiceParent(service)

# Start up our AMP.
TCPServer(25600, ConsoleRPCFactory(worlds)).setServiceParent(service)

application = Application("Bravo")
service.setServiceParent(application)
开发者ID:Estevo-Aleixo,项目名称:bravo,代码行数:28,代码来源:service.py

示例7: dict

# 需要导入模块: from twisted.application.service import MultiService [as 别名]
# 或者: from twisted.application.service.MultiService import setServiceParent [as 别名]
verbose = True

config = dict(hello="mum", goodbye="friend")
callbacks = {
    "player_play": lambda player: "Callback for Player '%s'" % (player)
}

top_service = MultiService()

reader = None

if ncurses_enabled:
    std_screen = curses.initscr()
    reader = Screen(std_screen)
    std_screen.refresh()
    reactor.addReader(reader)

sbs_service = SqueezeboxServerService(reader=reader, 
                                      config=config, 
                                      callbacks=callbacks,
                                      verbose=verbose)
sbs_service.setServiceParent(top_service)

factory = SqueezeboxServerFactory(sbs_service)
tcp_service = TCPClient(host, port, factory)
tcp_service.setServiceParent(top_service)

application = Application("pysqueezeboxserver")
top_service.setServiceParent(application)

开发者ID:jinglemansweep,项目名称:PySqueezeboxServer,代码行数:31,代码来源:run.py

示例8: load_role_config

# 需要导入模块: from twisted.application.service import MultiService [as 别名]
# 或者: from twisted.application.service.MultiService import setServiceParent [as 别名]
def load_role_config():
    config = StationConfig(blocked_roles=static_config["blocked_roles"])
    if isfile(static_config["dynamic_config"]):
        config.roles = load_json(static_config["dynamic_config"])
    return config


def save_role_config(roles):
    save_json(roles, static_config["dynamic_config"])

static_config = load_json("station.json")

role_config = load_role_config()

service_wrapper = MultiService()

configuration_manager_service = ConfigurationManagerService(role_config, update_callback=save_role_config)
configuration_manager_service.setServiceParent(service_wrapper)

transmit_service.setServiceParent(service_wrapper)

client = internet.TCPClient(static_config["manager_address"], static_config["manager_port"], StationClientFactory())
client.setServiceParent(service_wrapper)

application = Application("EventStreamr Station")
service_wrapper.setServiceParent(application)

if __name__ == "__main__":
    print "Please run this file using the following command - It makes life easier."
    print "\ttwistd --pidfile station.pid --nodaemon --python station.py"
开发者ID:leesdolphin,项目名称:eventstreamr,代码行数:32,代码来源:station.py


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