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


Python internet.TCPServer类代码示例

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


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

示例1: application

def application(config):
	app = Application("Scrapyd")
	http_port = config.getint('http_port', 6800)
	
	poller = QueuePoller(config)
	eggstorage = FilesystemEggStorage(config)
	scheduler = SpiderScheduler(config)
	environment = Environment(config)
	app.setComponent(IPoller, poller)
	app.setComponent(IEggStorage, eggstorage)
	app.setComponent(ISpiderScheduler, scheduler)
	app.setComponent(IEnvironment, environment)
	
	launcher = Launcher(config, app)
	timer = TimerService(5, poller.poll)
	root = Root(config, app)
	root = configRoot(root, config)
	
	webservice = TCPServer(http_port, server.Site(root))
	log.msg("Scrapyd web console available at http://localhost:%s/" % http_port)

	launcher.setServiceParent(app)
	timer.setServiceParent(app)
	webservice.setServiceParent(app)

	return app
开发者ID:huangpanxx,项目名称:POAS,代码行数:26,代码来源:app.py

示例2: build

    def build(cls, root_service):
        if not settings.ENABLE_MANHOLE:
            return

        factory = createManholeListener()
        service = TCPServer(settings.MANHOLE_PORT, factory, interface=settings.MANHOLE_INTERFACE)
        service.setServiceParent(root_service)
开发者ID:bmhatfield,项目名称:carbon,代码行数:7,代码来源:manhole.py

示例3: get_application

def get_application(config):
    app = Application('Scrapyd')
    http_port = config.getint('http_port', 6800)
    bind_address = config.get('bind_address', '0.0.0.0')
    poll_interval = config.getfloat('poll_interval', 5)

    poller = QueuePoller(config)
    eggstorage = FilesystemEggStorage(config)
    scheduler = SpiderScheduler(config)
    environment = Environment(config)

    app.setComponent(IPoller, poller)
    app.setComponent(IEggStorage, eggstorage)
    app.setComponent(ISpiderScheduler, scheduler)
    app.setComponent(IEnvironment, environment)

    laupath = config.get('launcher', 'scrapyd_mongodb.launcher.Launcher')
    laucls = load_object(laupath)
    launcher = laucls(config, app)

    timer = TimerService(poll_interval, poller.poll)
    webservice = TCPServer(
        http_port, server.Site(Root(config, app)),
        interface=bind_address)

    log.msg('http://%(bind_address)s:%(http_port)s/' % {'bind_address':bind_address, 'http_port':http_port})

    launcher.setServiceParent(app)
    timer.setServiceParent(app)
    webservice.setServiceParent(app)

    return app
开发者ID:Tiago-Lira,项目名称:scrapyd-mongodb,代码行数:32,代码来源:application.py

示例4: get_application

def get_application(arguments):
    ServiceRoot = load_object(settings.SERVICE_ROOT)
    site = Site(ServiceRoot())
    application = Application('scrapyrt')
    server = TCPServer(arguments.port, site, interface=arguments.ip)
    server.setServiceParent(application)
    return application
开发者ID:SmileyJames,项目名称:scrapyrt,代码行数:7,代码来源:cmdline.py

示例5: application

def application(config):
	app = Application("Scrapyd")
	http_port = config.getint('http_port', 6800)
	
	portal = Portal(PublicHTMLRealm(config, app), [FilePasswordDB(str(config.get('passwd', '')))])
	credentialFactory = DigestCredentialFactory("md5", "Go away")
	
	poller = QueuePoller(config)
	eggstorage = FilesystemEggStorage(config)
	scheduler = SpiderScheduler(config)
	environment = Environment(config)
	
	app.setComponent(IPoller, poller)
	app.setComponent(IEggStorage, eggstorage)
	app.setComponent(ISpiderScheduler, scheduler)
	app.setComponent(IEnvironment, environment)
	
	launcher = Launcher(config, app)
	timer = TimerService(5, poller.poll)
	webservice = TCPServer(http_port, server.Site(HTTPAuthSessionWrapper(portal, [credentialFactory])))
	log.msg("Scrapyd web console available at http://localhost:%s/" % http_port)
	
	launcher.setServiceParent(app)
	timer.setServiceParent(app)
	webservice.setServiceParent(app)
	
	return app
开发者ID:trunk,项目名称:littlespider,代码行数:27,代码来源:app.py

示例6: application

def application(config):
    app = Application("Scrapyd")
    http_port = config.getint('http_port', 6800)
    bind_address = config.get('bind_address', '0.0.0.0')

    poller = QueuePoller(config)
    eggstorage = FilesystemEggStorage(config)
    scheduler = SpiderScheduler(config)
    environment = Environment(config)

    app.setComponent(IPoller, poller)
    app.setComponent(IEggStorage, eggstorage)
    app.setComponent(ISpiderScheduler, scheduler)
    app.setComponent(IEnvironment, environment)

    laupath = config.get('launcher', 'scrapyd.launcher.Launcher')
    laucls = load_object(laupath)
    launcher = laucls(config, app)

    timer = TimerService(5, poller.poll)
    webservice = TCPServer(http_port, server.Site(Root(config, app)), interface=bind_address)
    log.msg("Scrapyd web console available at http://%s:%s/" % (bind_address, http_port))

    launcher.setServiceParent(app)
    timer.setServiceParent(app)
    webservice.setServiceParent(app)

    return app
开发者ID:Root-nix,项目名称:scrapy,代码行数:28,代码来源:app.py

示例7: application

def application(config, components=interfaces):
    app = Application("Scrapyd")
    http_port = config.getint('http_port', 6800)
    bind_address = config.get('bind_address', '0.0.0.0')

    for interface, key in interfaces:
        path = config.get(key)
        cls = load_object(path)
        component = cls(config)
        app.setComponent(interface, component)
    poller = component
        
    laupath = config.get('launcher', 'scrapyd.launcher.Launcher')
    laucls = load_object(laupath) 
    launcher = laucls(config, app)

    poll_every = config.getint("poll_every", 5)
    timer = TimerService(poll_every, poller.poll)
    
    webservice = TCPServer(http_port, server.Site(Root(config, app)), interface=bind_address)
    log.msg(format="Scrapyd web console available at http://%(bind_address)s:%(http_port)s/",
            bind_address=bind_address, http_port=http_port)

    launcher.setServiceParent(app)
    timer.setServiceParent(app)
    webservice.setServiceParent(app)

    return app
开发者ID:llonchj,项目名称:scrapyd,代码行数:28,代码来源:app.py

示例8: application

def application(config):
    app = Application("Scrapyd")
    http_port = int(environ.get('PORT', config.getint('http_port', 6800)))
    config.cp.set('scrapyd', 'database_url', environ.get('DATABASE_URL'))

    poller = Psycopg2QueuePoller(config)
    eggstorage = FilesystemEggStorage(config)
    scheduler = Psycopg2SpiderScheduler(config)
    environment = Environment(config)

    app.setComponent(IPoller, poller)
    app.setComponent(IEggStorage, eggstorage)
    app.setComponent(ISpiderScheduler, scheduler)
    app.setComponent(IEnvironment, environment)

    launcher = Launcher(config, app)
    timer = TimerService(5, poller.poll)
    webservice = TCPServer(http_port, server.Site(Root(config, app)))
    log.msg("Scrapyd web console available at http://localhost:%s/ (HEROKU)"
        % http_port)

    launcher.setServiceParent(app)
    timer.setServiceParent(app)
    webservice.setServiceParent(app)

    return app
开发者ID:kayawaffles,项目名称:scrapy-heroku,代码行数:26,代码来源:app.py

示例9: __init__

 def __init__(self, env):
     self.env = env
     http_port = env.config.getint('web', 'http_port') or HTTP_PORT
     log_file = env.config.get('web', 'http_log_file') or None
     if not os.path.isabs(log_file):
         log_file = os.path.join(self.env.config.path, log_file)
     factory = WebServiceFactory(env, log_file)
     TCPServer.__init__(self, http_port, factory)
开发者ID:barsch,项目名称:seishub.core,代码行数:8,代码来源:web.py

示例10: __init__

   def __init__(self, dbpool, services):
      self.dbpool = dbpool
      self.services = services
      self.isRunning = False

      port = services["config"]["flash-policy-port"]
      factory = FlashPolicyFactory(services["config"])
      TCPServer.__init__(self, port, factory)
开发者ID:jamjr,项目名称:crossbar,代码行数:8,代码来源:flashpolicy.py

示例11: makeService

 def makeService(self, options):
     """
     Construct the mapiphany
     """
     from mapiphany.webserver import WebSite
     site = WebSite()
     ws = TCPServer(int(options['port']), site)
     ws.site = site
     return ws
开发者ID:corydodt,项目名称:Mapiphany,代码行数:9,代码来源:mapiphanytap.py

示例12: makeService

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
开发者ID:timstaley,项目名称:Comet,代码行数:56,代码来源:broker.py

示例13: _makeSiteService

 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
开发者ID:cloudbase,项目名称:maas,代码行数:10,代码来源:plugin.py

示例14: configure_services

    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)
开发者ID:Mortal,项目名称:bravo,代码行数:30,代码来源:service.py

示例15: configure_service

 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)
开发者ID:gtaylor,项目名称:zombiepygman,代码行数:11,代码来源:service.py


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