• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python internet.TCPServer类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: makeService

    def makeService(self, options):
        top_service = service.MultiService()

        server_service = ServerService(options["map"], int(options["numplayers"]))
        server_service.setServiceParent(top_service)

        server_factory = MyServerFactory(server_service)

        server = TCPServer(int(options["port"]), server_factory)
        server.setServiceParent(top_service)

        return top_service
开发者ID:shurtado,项目名称:SnakesOnABoat,代码行数:12,代码来源:server_plugin.py


示例17: create_status_service

def create_status_service(storage, parent_service, port, user_id=0, ssl_context_factory=None):
    """Create the status service."""
    root = resource.Resource()
    root.putChild("status", _Status(storage, user_id))
    root.putChild("+meliae", MeliaeResource())
    root.putChild("+gc-stats", GCResource())
    site = server.Site(root)
    if ssl_context_factory is None:
        service = TCPServer(port, site)
    else:
        service = SSLServer(port, site, ssl_context_factory)
    service.setServiceParent(parent_service)
    return service
开发者ID:cloudfleet,项目名称:filesync-server,代码行数:13,代码来源:stats.py


示例18: __init__

   def __init__(self, dbpool, services, reactor = None):
      ## lazy import to avoid reactor install upon module import
      if reactor is None:
         from twisted.internet import reactor
      self.reactor = reactor

      self.dbpool = dbpool
      self.services = services
      self.isRunning = False

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


示例19: application

def application(config):
    app = Application("Scrapyd")
    http_port = config.getint('http_port', 6800)
    bind_address = config.get('bind_address', '127.0.0.1')
    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.launcher.Launcher')
    laucls = load_object(laupath)
    launcher = laucls(config, app)

    timer = TimerService(poll_interval, poller.poll)

    webpath = config.get('webroot', 'scrapyd.website.Root')
    webcls = load_object(webpath)

    username = config.get('username', '')
    password = config.get('password', '')
    if username and password:
        if ':' in username:
            sys.exit("The `username` option contains illegal character ':', "
                     "check and update the configuration file of Scrapyd")
        portal = Portal(PublicHTMLRealm(webcls(config, app)),
                        [StringCredentialsChecker(username, password)])
        credential_factory = BasicCredentialFactory("Auth")
        resource = HTTPAuthSessionWrapper(portal, [credential_factory])
        log.msg("Basic authentication enabled")
    else:
        resource = webcls(config, app)
        log.msg("Basic authentication disabled as either `username` or `password` is unset")
    webservice = TCPServer(http_port, server.Site(resource), 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:scrapy,项目名称:scrapyd,代码行数:48,代码来源:app.py


示例20: setupWriterProcessor

def setupWriterProcessor(root_service, settings):
    from carbon import cache  # Register CacheFeedingProcessor
    from carbon.protocols import CacheManagementHandler
    from carbon.writer import WriterService
    from carbon import events

    factory = ServerFactory()
    factory.protocol = CacheManagementHandler
    service = TCPServer(settings.CACHE_QUERY_PORT, factory, interface=settings.CACHE_QUERY_INTERFACE)
    service.setServiceParent(root_service)

    writer_service = WriterService()
    writer_service.setServiceParent(root_service)

    if settings.USE_FLOW_CONTROL:
        events.cacheFull.addHandler(events.pauseReceivingMetrics)
        events.cacheSpaceAvailable.addHandler(events.resumeReceivingMetrics)
开发者ID:rlugojr,项目名称:carbon,代码行数:17,代码来源:service.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python internet.TimerService类代码示例发布时间:2022-05-27
下一篇:
Python internet.StreamServerEndpointService类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap