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

Python strports.service函数代码示例

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

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



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

示例1: makeService

def makeService(config):
    if config['logfile']:
        logObserver = log.FileAccessLoggingObserver(config['logfile'])
    else:
        logObserver = log.DefaultCommonAccessLoggingObserver()

    if config['root']:
        if config['indexes']:
            config['root'].indexNames = config['indexes']
            
        root = log.LogWrapperResource(config['root'])


    s = Web2Service(logObserver)

    site = server.Site(root)
    chan = channel.HTTPFactory(site)
    
    if config['https']:
        from twisted.internet.ssl import DefaultOpenSSLContextFactory
        i = internet.SSLServer(int(config['https']), chan,
                               DefaultOpenSSLContextFactory(config['privkey'],
                                                            config['certificate']))
        i.setServiceParent(s)
        
    strports.service(config['port'], chan
                     ).setServiceParent(s)

    return s
开发者ID:lzimm,项目名称:360io,代码行数:29,代码来源:tap.py


示例2: makeService

def makeService(config):
    s = service.MultiService()
    if config['root']:
        root = config['root']
        if config['indexes']:
            config['root'].indexNames = config['indexes']
    else:
        # This really ought to be web.Admin or something
        root = demo.Test()

    if isinstance(root, static.File):
        root.registry.setComponent(interfaces.IServiceCollection, s)

    if config['logfile']:
        site = server.Site(root, logPath=config['logfile'])
    else:
        site = server.Site(root)

    site.displayTracebacks = not config["notracebacks"]

    if config['personal']:
        personal = strports.service(
            config['port'], makePersonalServerFactory(site))
        personal.setServiceParent(s)
    else:
        if config['https']:
            from twisted.internet.ssl import DefaultOpenSSLContextFactory
            i = internet.SSLServer(int(config['https']), site,
                          DefaultOpenSSLContextFactory(config['privkey'],
                                                       config['certificate']))
            i.setServiceParent(s)
        strports.service(config['port'], site).setServiceParent(s)

    return s
开发者ID:Almad,项目名称:twisted,代码行数:34,代码来源:tap.py


示例3: test_serviceDeprecatedDefault

    def test_serviceDeprecatedDefault(self):
        """
        L{strports.service} still accepts a 'default' argument, which will
        affect the parsing of 'default' (i.e. 'not containing a colon')
        endpoint descriptions, but this behavior is deprecated.
        """
        svc = strports.service("8080", None, "unix")
        self.assertIsInstance(svc.endpoint, UNIXServerEndpoint)
        warnings = self.flushWarnings([self.test_serviceDeprecatedDefault])
        self.assertEqual(warnings[0]['category'], DeprecationWarning)
        self.assertEqual(
            warnings[0]['message'],
            "The 'default' parameter was deprecated in Twisted 10.2.0.  "
            "Use qualified endpoint descriptions; for example, 'tcp:8080'.")
        self.assertEqual(len(warnings), 1)

        # Almost the same case, but slightly tricky - explicitly passing the
        # old default value, None, also must trigger a deprecation warning.
        svc = strports.service("tcp:8080", None, None)
        self.assertIsInstance(svc.endpoint, TCP4ServerEndpoint)
        warnings = self.flushWarnings([self.test_serviceDeprecatedDefault])
        self.assertEqual(warnings[0]['category'], DeprecationWarning)
        self.assertEqual(
            warnings[0]['message'],
            "The 'default' parameter was deprecated in Twisted 10.2.0.")
        self.assertEqual(len(warnings), 1)
开发者ID:Architektor,项目名称:PySnip,代码行数:26,代码来源:test_strports.py


示例4: makeService

def makeService (config_global, config, ) :
    sys.path.insert(0, config_global.get("root"), )
    os.environ["DJANGO_SETTINGS_MODULE"] = config.get("django-settings")

    _ms = service.MultiService()

    # `HTTP` interface
    _resource = RootResource()
    _resource.putChild("file", FileResource(config.get("file-directory"), ), )

    strports.service(
        "tcp:%d%s" % (
            config.get("file-port"),
            config_global.get("interface"),
        ),
        HTTPFactory(
                _resource,
                is_stand="--nodaemon" in sys.argv or "-n" in sys.argv,
                quite=config_global.get("quite"),
            ),
    ).setServiceParent(_ms, )

    XMPPClient(
            "[email protected]%s" % config_global.get("hostname"),
            "io.data",
            host=config_global.get("xmpp-host"),
            port=config_global.get("xmpp-port"),
            file_directory=config.get("file-directory"),
        ).setServiceParent(_ms, )

    return _ms
开发者ID:srothan,项目名称:io,代码行数:31,代码来源:data.py


示例5: makeService

    def makeService(self, options):
        master = Master(options)

        web = Web(master)
        strports.service(options["web"], web).setServiceParent(master)

        return master
开发者ID:Haidaraaaaa,项目名称:Servrhe,代码行数:7,代码来源:servrhe.py


示例6: makeService

def makeService(config):
    s = service.MultiService()

    router = component.Router()

    # Set up the XMPP server service

    serverService = server.ServerService(router, secret=config['server-secret'])
    serverService.domains = config['domains']
    serverService.logTraffic = config['verbose']

    # Hook up XMPP server-to-server service
    s2sFactory = server.XMPPS2SServerFactory(serverService)
    s2sFactory.logTraffic = config['verbose']
    s2sService = strports.service(config['server-port'], s2sFactory)
    s2sService.setServiceParent(s)

    # Hook up XMPP external server-side component service
    cFactory = component.XMPPComponentServerFactory(router,
                                                    config['component-secret'])

    cFactory.logTraffic = config['verbose']
    cServer = strports.service(config['component-port'], cFactory)
    cServer.setServiceParent(s)

    return s
开发者ID:Gandi,项目名称:wokkel,代码行数:26,代码来源:componentservertap.py


示例7: __init__

 def __init__(self, relayport, transitport, advertise_version):
     service.MultiService.__init__(self)
     self.db = get_db("relay.sqlite")
     welcome = {
         "current_version": __version__,
         # adding .motd will cause all clients to display the message,
         # then keep running normally
         #"motd": "Welcome to the public relay.\nPlease enjoy this service.",
         #
         # adding .error will cause all clients to fail, with this message
         #"error": "This server has been disabled, see URL for details.",
         }
     if advertise_version:
         welcome["current_version"] = advertise_version
     self.root = Root()
     site = server.Site(self.root)
     self.relayport_service = strports.service(relayport, site)
     self.relayport_service.setServiceParent(self)
     self.relay = Relay(self.db, welcome) # accessible from tests
     self.root.putChild("wormhole-relay", self.relay)
     t = internet.TimerService(EXPIRATION_CHECK_PERIOD,
                               self.relay.prune_old_channels)
     t.setServiceParent(self)
     if transitport:
         self.transit = Transit()
         self.transit.setServiceParent(self) # for the timer
         self.transport_service = strports.service(transitport, self.transit)
         self.transport_service.setServiceParent(self)
开发者ID:negativo,项目名称:magic-wormhole,代码行数:28,代码来源:relay.py


示例8: makeService

def makeService(config):
	from twisted.internet import reactor, task

	multi = service.MultiService()

	domain = config['domain']
	mutils.maybeWarnAboutDomain(reactor, domain)

	closureLibrary = FilePath(config['closure-library'])
	mutils.maybeWarnAboutClosureLibrary(reactor, closureLibrary)

	socketPorts = []
	for minervaStrport in config['minerva']:
		_, _args, _ = strports.parse(minervaStrport, object())
		socketPorts.append(_args[0])

	doReloading = bool(int(os.environ.get('PYRELOADING', '0')))
	fileCache = FileCache(lambda: reactor.seconds(), 0.1 if doReloading else -1)
	stf, httpSite = demosminerva_site.makeMinervaAndHttp(
		reactor, fileCache, socketPorts, domain, closureLibrary)
	httpSite.displayTracebacks = not config["no-tracebacks"]

	for httpStrport in config['http']:
		httpServer = strports.service(httpStrport, httpSite)
		httpServer.setServiceParent(multi)

	for minervaStrport in config['minerva']:
		minervaServer = strports.service(minervaStrport, stf)
		minervaServer.setServiceParent(multi)

	if doReloading:
		mutils.enablePyquitter(reactor)

	return multi
开发者ID:ludios,项目名称:DemosMinerva,代码行数:34,代码来源:tap.py


示例9: makeService

def makeService(config):
    from twisted.internet import reactor

    multi = service.MultiService()

    domain = config['domain']
    mutils.maybeWarnAboutDomain(reactor, domain)

    closureLibrary = FilePath(config['closure-library'])
    mutils.maybeWarnAboutClosureLibrary(reactor, closureLibrary)

    socketPorts = []
    for minervaStrport in config['minerva']:
            _, _args, _ = strports.parse(minervaStrport, object())
            socketPorts.append(_args[0])

    fileCache = FileCache(lambda: reactor.seconds(), -1)
    stf, httpSite = site.setupMinerva(
            reactor, fileCache, socketPorts, domain, closureLibrary
    )
    httpSite.displayTracebacks = not config["no-tracebacks"]

    for httpStrport in config['http']:
            httpServer = strports.service(httpStrport, httpSite)
            httpServer.setServiceParent(multi)

    for minervaStrport in config['minerva']:
            minervaServer = strports.service(minervaStrport, stf)
            minervaServer.setServiceParent(multi)

    return multi
开发者ID:Julian,项目名称:cardboard,代码行数:31,代码来源:config.py


示例10: makeService

def makeService(options):
    """Create a manhole server service.

    @type options: C{dict}
    @param options: A mapping describing the configuration of
    the desired service.  Recognized key/value pairs are::

        "telnetPort": strports description of the address on which
                      to listen for telnet connections.  If None,
                      no telnet service will be started.

        "sshPort": strports description of the address on which to
                   listen for ssh connections.  If None, no ssh
                   service will be started.

        "namespace": dictionary containing desired initial locals
                     for manhole connections.  If None, an empty
                     dictionary will be used.

        "passwd": Name of a passwd(5)-format username/password file.

    @rtype: L{twisted.application.service.IService}
    @return: A manhole service.
    """

    svc = service.MultiService()

    namespace = options['namespace']
    if namespace is None:
        namespace = {}

    checker = checkers.FilePasswordDB(options['passwd'])

    if options['telnetPort']:
        telnetRealm = _StupidRealm(telnet.TelnetBootstrapProtocol,
                                   insults.ServerProtocol,
                                   manhole.ColoredManhole,
                                   namespace)

        telnetPortal = portal.Portal(telnetRealm, [checker])

        telnetFactory = protocol.ServerFactory()
        telnetFactory.protocol = makeTelnetProtocol(telnetPortal)
        telnetService = strports.service(options['telnetPort'],
                                         telnetFactory)
        telnetService.setServiceParent(svc)

    if options['sshPort']:
        sshRealm = manhole_ssh.TerminalRealm()
        sshRealm.chainedProtocolFactory = chainedProtocolFactory(namespace)

        sshPortal = portal.Portal(sshRealm, [checker])
        sshFactory = manhole_ssh.ConchFactory(sshPortal)
        sshService = strports.service(options['sshPort'],
                                      sshFactory)
        sshService.setServiceParent(svc)

    return svc
开发者ID:timkrentz,项目名称:SunTracker,代码行数:58,代码来源:manhole_tap.py


示例11: makeService

def makeService(config):
    """
    Set up the otter-api service.
    """
    s = MultiService()
    core = MimicCore.fromPlugins(Clock())
    root = MimicRoot(core)
    site = Site(root.app.resource())
    site.displayTracebacks = False
    service(config['listen'], site).setServiceParent(s)
    return s
开发者ID:jirwin,项目名称:mimic,代码行数:11,代码来源:tap.py


示例12: makeService

 def makeService(self, options):
     s = MultiService()
     tps = ThreadPoolService()
     tps.setServiceParent(s)
     site = Site(
         RootResource(
             store=Store(options['dbdir']),
             steamKey=options['steamkey'],
             paypalSandbox=options['paypal-sandbox'],
             threadPool=tps.threadpool))
     strports.service(options['port'], site).setServiceParent(s)
     return s
开发者ID:ddormer,项目名称:bdm,代码行数:12,代码来源:blood_service.py


示例13: makeService

def makeService(config):
    computername = unicode(os.popen("/usr/sbin/networksetup -getcomputername",
                                    "r").readlines()[0]).strip()
    s = service.MultiService()

    for host_config in config['hosts']:

        prepareMultiService(s, host_config)

        if host_config['vhosts']:

            vhost_root = vhost.NameVirtualHost()
            vhost_root.default = host_config['root']

            for vhost_config in host_config['vhosts']:

                prepareMultiService(s, vhost_config)

                vhost_root.addHost(vhost_config['fqdn'], vhost_config['root'])

            host_config['root'] = vhost_root

        if config['logfile']:
            site = server.Site(host_config['root'], logPath=config['logfile'])
        else:
            site = server.Site(host_config['root'])

        site.displayTracebacks = not config["notracebacks"]

        if not host_config['shape'] is None:
            site.protocol = shaper.gen_token_bucket(site.protocol,
                                                    *host_config['shape'])

        port = host_config['port']
        if ":" in str(host_config['port']):
            port = host_config['port'].split(':', 2)[1]
        port = int(port)

        if not host_config['bonjour']:
            host_config['bonjour'].append(u"Mediacast-Webserver (%s on port %d)")

        for bonjour_desc in host_config['bonjour']:
            if '%s' in bonjour_desc and '%d' in bonjour_desc:
                bonjour_desc %= (computername, port)
            elif '%s' in bonjour_desc:
                bonjour_desc %= computername
            elif '%d' in bonjour_desc:
                bonjour_desc %= port
            bonjour.mDNSService(bonjour_desc, "_http._tcp", port).setServiceParent(s)

        strports.service(host_config['port'], site).setServiceParent(s)

    return s
开发者ID:sjorek,项目名称:mediacastserver,代码行数:53,代码来源:server.py


示例14: makeService

 def makeService(self, options):
     """
     Construct a TCPServer from a factory defined in myproject.
     """
     player = Player(reactor)
     reactor.addSystemEventTrigger("before", "shutdown", player.kill)
     s = service.MultiService()
     payload_service = strports.service(options["payload"],                                   
                                        CustomServer(PayloadProtocol, player))
     payload_service.setServiceParent(s)
     control_service = strports.service(options["control"],
                                        CustomServer(ControlProtocol, player))
     control_service.setServiceParent(s)
     return s
开发者ID:nanonyme,项目名称:nanoplay,代码行数:14,代码来源:nanoplay_plugin.py


示例15: startService

    def startService(self):
        def chainedProtocolFactory():
            def getManhole():
                return Manhole({"store": self.store})

            protocol = insults.ServerProtocol(ColoredManhole)
            protocol.protocolFactory = getManhole
            return protocol

        checker = checkers.InMemoryUsernamePasswordDatabaseDontUse(**{str(self.username): self.password})
        realm = TerminalRealm()
        realm.chainedProtocolFactory = chainedProtocolFactory
        p = portal.Portal(realm, [checker])
        strports.service(self.listen, ConchFactory(p)).setServiceParent(self.parent)
开发者ID:bne,项目名称:squeal,代码行数:14,代码来源:manhole.py


示例16: makeService

def makeService(config):
    """
    Set up the otter-api service.
    """
    s = MultiService()
    if config['realtime']:
        from twisted.internet import reactor as clock
    else:
        clock = Clock()
    core = MimicCore.fromPlugins(clock)
    root = MimicRoot(core, clock)
    site = get_site(root.app.resource(), logging=bool(config['verbose']))
    service(config['listen'], site).setServiceParent(s)
    return s
开发者ID:BenjamenMeyer,项目名称:mimic,代码行数:14,代码来源:tap.py


示例17: makeService

    def makeService(self, config):
        s = service.MultiService()
        if config['root']:
            root = config['root']
            if config['indexes']:
                config['root'].indexNames = config['indexes']
        else:
            # This really ought to be web.Admin or something
            root = demo.Test()

        if isinstance(root, static.File):
            root.registry.setComponent(interfaces.IServiceCollection, s)

        if config['logfile']:
            site = server.Site(root, logPath=config['logfile'])
        else:
            site = server.Site(root)

        site.displayTracebacks = not config["notracebacks"]
        
        if config['personal']:
            personal = strports.service(
                config['port'], makePersonalServerFactory(site))
            personal.setServiceParent(s)
        else:
            if config['https']:
                from twisted.internet.ssl import DefaultOpenSSLContextFactory
                if config['sslmethod'].lower() == "sslv2":
                    ssl_method = SSL.SSLv2_METHOD
                elif config['sslmethod'].lower() == "sslv3":
                    ssl_method = SSL.SSLv3_METHOD
                elif config['sslmethod'].lower() == "sslv23":
                    ssl_method = SSL.SSLv23_METHOD
                elif config['sslmethod'].lower() == "tlsv1":
                    ssl_method = SSL.TLSv1_METHOD
                elif config['sslmethod'].lower() == "tlsv1_1":
                    ssl_method = SSL.TLSv1_1_METHOD
                elif config['sslmethod'].lower() == "tlsv1_2":
                    ssl_method = SSL.TLSv1_2_METHOD
                else:
                    raise usage.UsageError("Invalid SSL method: %s" % config['sslmethod'].lower())
            
                i = internet.SSLServer(int(config['https']), site,
                              DefaultOpenSSLContextFactory(config['privkey'],
                                                           config['certificate'],
                                                           ssl_method))
                i.setServiceParent(s)
            strports.service(config['port'], site).setServiceParent(s)

        return s
开发者ID:williamsjj,项目名称:httpsink,代码行数:50,代码来源:httpsinklib.py


示例18: makeService

def makeService(config):
    """
    Set up the otter-api service.
    """
    s = MultiService()
    if config['realtime']:
        from twisted.internet import reactor as clock
    else:
        clock = Clock()
    core = MimicCore.fromPlugins(clock)
    root = MimicRoot(core, clock)
    site = Site(root.app.resource())
    site.displayTracebacks = False
    service(config['listen'], site).setServiceParent(s)
    return s
开发者ID:amitgandhinz,项目名称:mimic,代码行数:15,代码来源:tap.py


示例19: makeService

def makeService(config):
    s = MultiService()

    proxy = strports.service(
        config['proxy'],
        server.Site(TrickProxyResource(config['requestTricks'], config['responseTricks'])))
    proxy.setServiceParent(s)

    ui = strports.service(
        config['ui'],
        server.Site(Root())
    )
    ui.setServiceParent(s)

    return s
开发者ID:dreid,项目名称:loki,代码行数:15,代码来源:tap.py


示例20: makeService

def makeService(config):
    """
    Create a punjab service to run
    """
    from twisted.web import server, resource, static
    from twisted.application import internet

    from . import httpb

    serviceCollection = PunjabService()

    if config['html_dir']:
        r = static.File(config['html_dir'])
    else:
        print("The html directory is needed.")
        return

    if config['white_list']:
        httpb.HttpbService.white_list = config['white_list'].split(',')

    if config['black_list']:
        httpb.HttpbService.black_list = config['black_list'].split(',')

    if config['httpb']:
        b = httpb.HttpbService(config['verbose'], config['polling'])
        if config['httpb'] == '':
            r.putChild(b'http-bind', resource.IResource(b))
        else:
            r.putChild(config['httpb'].encode('utf-8'), resource.IResource(b))

    if config['site_log_file']:
        site = server.Site(r, logPath=config['site_log_file'])
    else:
        site = server.Site(r)

    if config['strports']:
        for strport in config['strports']:
            sm = strports.service(
                strport,
                site,
            )
            sm.setServiceParent(serviceCollection)
    elif config['ssl']:
        from OpenSSL import SSL
        from punjab.ssl import OpenSSLContextFactoryChaining
        ssl_context = OpenSSLContextFactoryChaining(config['ssl_privkey'],
                                                    config['ssl_cert'],
                                                    SSL.SSLv23_METHOD,)
        sm = internet.SSLServer(int(config['port']),
                                site,
                                ssl_context,
                                backlog=int(config['verbose']))
        sm.setServiceParent(serviceCollection)
    else:
        sm = internet.TCPServer(int(config['port']), site)

        sm.setServiceParent(serviceCollection)

    serviceCollection.httpb = b
    return serviceCollection
开发者ID:twonds,项目名称:punjab,代码行数:60,代码来源:__init__.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python avatar.ConchUser类代码示例发布时间:2022-05-27
下一篇:
Python strports.parse函数代码示例发布时间: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