本文整理汇总了Python中twisted.application.internet.TCPServer.setName方法的典型用法代码示例。如果您正苦于以下问题:Python TCPServer.setName方法的具体用法?Python TCPServer.setName怎么用?Python TCPServer.setName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类twisted.application.internet.TCPServer
的用法示例。
在下文中一共展示了TCPServer.setName方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: makeService
# 需要导入模块: from twisted.application.internet import TCPServer [as 别名]
# 或者: from twisted.application.internet.TCPServer import setName [as 别名]
def makeService(config):
event_db = Event_DB(config['eventdb'])
LoopingCall(event_db.prune, MAX_AGE).start(PRUNE_INTERVAL)
broker_service = MultiService()
if config['broadcast']:
broadcaster_factory = VOEventBroadcasterFactory(
config["local-ivo"], config['broadcast-test-interval']
)
if log.LEVEL >= log.Levels.INFO: broadcaster_factory.noisy = False
broadcaster_service = TCPServer(
config['broadcast-port'],
broadcaster_factory
)
broadcaster_service.setName("Broadcaster")
broadcaster_service.setServiceParent(broker_service)
# If we're running a broadcast, we will rebroadcast any events we
# receive to it.
config['handlers'].append(EventRelay(broadcaster_factory))
if config['receive']:
receiver_factory = VOEventReceiverFactory(
local_ivo=config['local-ivo'],
validators=[
CheckPreviouslySeen(event_db),
CheckSchema(
os.path.join(comet.__path__[0], "schema/VOEvent-v2.0.xsd")
),
CheckIVORN()
],
handlers=config['handlers']
)
if log.LEVEL >= log.Levels.INFO: receiver_factory.noisy = False
whitelisting_factory = WhitelistingFactory(receiver_factory, config['whitelist'])
if log.LEVEL >= log.Levels.INFO: whitelisting_factory.noisy = False
receiver_service = TCPServer(config['receive-port'], whitelisting_factory)
receiver_service.setName("Receiver")
receiver_service.setServiceParent(broker_service)
for host, port in config["remotes"]:
subscriber_factory = VOEventSubscriberFactory(
local_ivo=config["local-ivo"],
validators=[CheckPreviouslySeen(event_db)],
handlers=config['handlers'],
filters=config['filters']
)
if log.LEVEL >= log.Levels.INFO: subscriber_factory.noisy = False
remote_service = TCPClient(host, port, subscriber_factory)
remote_service.setName("Remote %s:%d" % (host, port))
remote_service.setServiceParent(broker_service)
if not broker_service.services:
reactor.callWhenRunning(log.warning, "No services requested; stopping.")
reactor.callWhenRunning(reactor.stop)
return broker_service
示例2: _makeSiteService
# 需要导入模块: from twisted.application.internet import TCPServer [as 别名]
# 或者: from twisted.application.internet.TCPServer import setName [as 别名]
def _makeSiteService(self, papi_xmlrpc, config):
"""Create the site service."""
site_root = Resource()
site_root.putChild("api", papi_xmlrpc)
site = Site(site_root)
site_port = config["port"]
site_interface = config["interface"]
site_service = TCPServer(site_port, site, interface=site_interface)
site_service.setName("site")
return site_service
示例3: configure_service
# 需要导入模块: from twisted.application.internet import TCPServer [as 别名]
# 或者: from twisted.application.internet.TCPServer import setName [as 别名]
def configure_service(self):
"""
Instantiation and startup for the RESTful API.
"""
root = APIResource()
factory = Site(root)
port = settings.API_PORT
server = TCPServer(port, factory)
server.setName("WebAPI")
self.addService(server)
示例4: makeService
# 需要导入模块: from twisted.application.internet import TCPServer [as 别名]
# 或者: from twisted.application.internet.TCPServer import setName [as 别名]
def makeService(config):
'''
Create service tree. Only one tracker can be used for every protocol!
@param config: instance of an Options class with configuration parameters.
@type config: C{twisted.python.usage.Options}
@return: service collection
@rtype: C{twisted.application.service.IServiceCollection}
'''
from gorynych.receiver.factories import ReceivingFactory
from gorynych.receiver import protocols, parsers
from gorynych.receiver.receiver import ReceiverRabbitQueue, ReceiverService, AuditFileLog
# Set up application.
application = service.Application("ReceiverServer")
sc = service.IServiceCollection(application)
# Prepare receiver.
audit_log = AuditFileLog('audit_log')
sender = ReceiverRabbitQueue(host='localhost', port=5672,
exchange='receiver', exchange_type='fanout')
parser = getattr(parsers, config['tracker'])()
sender.setName('RabbitMQReceiverService')
sender.setServiceParent(sc)
receiver_service = ReceiverService(sender, audit_log, parser)
receiver_service.setName('ReceiverService')
receiver_service.setServiceParent(sc)
if 'tcp' in config['protocols']:
receiver_server = TCPServer(config['port'],
ReceivingFactory(receiver_service))
protocol = getattr(protocols,
'_'.join((config['tracker'], 'tcp', 'protocol')))
receiver_server.args[1].protocol = protocol
receiver_server.setName(config['tracker'] + '_tcp')
receiver_server.setServiceParent(sc)
if 'udp' in config['protocols']:
protocol = getattr(protocols,
'_'.join((config['tracker'], 'udp', 'protocol')))(receiver_service)
receiver_server = UDPServer(config['port'], protocol)
receiver_server.setName(config['tracker'] + '_udp')
receiver_server.setServiceParent(sc)
return sc
示例5: makeService
# 需要导入模块: from twisted.application.internet import TCPServer [as 别名]
# 或者: from twisted.application.internet.TCPServer import setName [as 别名]
def makeService(self, options):
"""
Create a service which will run a Gam3 server.
@param options: mapping of configuration
"""
from pygame.image import load
from gam3.network import Gam3Factory
from gam3.world import (
TCP_SERVICE_NAME, GAM3_SERVICE_NAME, Gam3Service, World)
from game.terrain import loadTerrainFromString, loadTerrainFromSurface
from twisted.python.filepath import FilePath
from twisted.internet import reactor
from twisted.application.service import MultiService
from twisted.protocols.policies import TrafficLoggingFactory
world = World(granularity=100, platformClock=reactor)
terrain = options['terrain']
if terrain:
if terrain.endswith('.png'):
voxels = loadTerrainFromSurface(load(terrain)).voxels
else:
raw = FilePath(terrain).getContent()
voxels = loadTerrainFromString(raw)
world.terrain.set(0, 0, 0, voxels)
service = MultiService()
factory = Gam3Factory(world)
if options['log-directory'] is not None:
factory = TrafficLoggingFactory(
factory, join(options['log-directory'], 'gam3'))
tcp = TCPServer(options['port'], factory)
tcp.setName(TCP_SERVICE_NAME)
tcp.setServiceParent(service)
gam3 = Gam3Service(world)
gam3.setName(GAM3_SERVICE_NAME)
gam3.setServiceParent(service)
return service
示例6: configure_services
# 需要导入模块: from twisted.application.internet import TCPServer [as 别名]
# 或者: from twisted.application.internet.TCPServer import setName [as 别名]
def configure_services(self, configuration):
read_configuration()
for section in configuration.sections():
if section.startswith("world "):
factory = BravoFactory(section[6:])
server = TCPServer(factory.port, factory,
interface=factory.interface)
server.setName(factory.name)
self.addService(server)
elif section.startswith("irc "):
try:
from bravo.irc import BravoIRC
except ImportError:
log.msg("Couldn't import IRC stuff!")
else:
factory = BravoIRC(self.namedServices, section[4:])
client = TCPClient(factory.host, factory.port, factory)
client.setName(factory.name)
self.addService()
elif section.startswith("infiniproxy "):
factory = BetaProxyFactory(section[12:])
server = TCPServer(factory.port, factory)
server.setName(factory.name)
self.addService(server)
elif section.startswith("infininode "):
factory = InfiniNodeFactory(section[11:])
server = TCPServer(factory.port, factory)
server.setName(factory.name)
self.addService(server)
示例7: configure_services
# 需要导入模块: from twisted.application.internet import TCPServer [as 别名]
# 或者: from twisted.application.internet.TCPServer import setName [as 别名]
def configure_services(self, configuration):
read_configuration()
for section in configuration.sections():
if section.startswith("world "):
factory = BravoFactory(section[6:])
server = TCPServer(factory.port, factory,
interface=factory.interface)
server.setName(factory.name)
self.addService(server)
self.factorylist.append(factory)
elif section == "web":
try:
from bravo.web import bravo_site
except ImportError:
log.msg("Couldn't import web stuff!")
else:
factory = bravo_site(self.namedServices)
port = configuration.getint("web", "port")
server = TCPServer(port, factory)
server.setName("web")
self.addService(server)
elif section.startswith("irc "):
try:
from bravo.irc import BravoIRC
except ImportError:
log.msg("Couldn't import IRC stuff!")
else:
self.irc = True
self.ircbots.append(section)
elif section.startswith("infiniproxy "):
factory = BetaProxyFactory(section[12:])
server = TCPServer(factory.port, factory)
server.setName(factory.name)
self.addService(server)
elif section.startswith("infininode "):
factory = InfiniNodeFactory(section[11:])
server = TCPServer(factory.port, factory)
server.setName(factory.name)
self.addService(server)
if self.irc:
for section in self.ircbots:
factory = BravoIRC(self.factorylist, section[4:])
client = TCPClient(factory.host, factory.port, factory)
client.setName(factory.config)
self.addService(client)