本文整理汇总了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)
示例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)
示例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)
示例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
示例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)
示例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)
示例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)
示例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"