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


Python Site.noisy方法代码示例

本文整理汇总了Python中twisted.web.server.Site.noisy方法的典型用法代码示例。如果您正苦于以下问题:Python Site.noisy方法的具体用法?Python Site.noisy怎么用?Python Site.noisy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在twisted.web.server.Site的用法示例。


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

示例1: _create_web_factory

# 需要导入模块: from twisted.web.server import Site [as 别名]
# 或者: from twisted.web.server.Site import noisy [as 别名]
    def _create_web_factory(self, config):

        options = config.get('options', {})

        # create Twisted Web root resource
        if '/' in config['paths']:
            root_config = config['paths']['/']
            root = self._create_resource(root_config, nested=False)
        else:
            root = Resource404(self._templates, b'')

        # create Twisted Web resources on all non-root paths configured
        self._add_paths(root, config.get('paths', {}))

        # create the actual transport factory
        transport_factory = Site(root)
        transport_factory.noisy = False

        # Web access logging
        if not options.get('access_log', False):
            transport_factory.log = lambda _: None

        # Traceback rendering
        transport_factory.displayTracebacks = options.get('display_tracebacks', False)

        # HSTS
        if options.get('hsts', False):
            if 'tls' in config['endpoint']:
                hsts_max_age = int(options.get('hsts_max_age', 31536000))
                transport_factory.requestFactory = createHSTSRequestFactory(transport_factory.requestFactory, hsts_max_age)
            else:
                self.log.warn("Warning: HSTS requested, but running on non-TLS - skipping HSTS")

        return transport_factory
开发者ID:david-e,项目名称:crossbar,代码行数:36,代码来源:router.py

示例2: __init__

# 需要导入模块: from twisted.web.server import Site [as 别名]
# 或者: from twisted.web.server.Site import noisy [as 别名]
    def __init__(self, queue):
        self.queue = queue

        # set up handler to drop emails from the 'queue' into the main queue
        lc = task.LoopingCall(self.processSockets)
        lc.start(2)

        # fire up static server while we're here
        staticResource = File('./static/dist')
        staticFactory = Site(staticResource, logPath=os.devnull)
        staticFactory.noisy = False

        if Config.useSSL:
            contextFactory = ssl.DefaultOpenSSLContextFactory(
                Config.keyFile,
                Config.certFile
            )

            # static HTTPS serving
            reactor.listenSSL(Config.httpsPort, staticFactory, contextFactory)

            # WSS
            WSfactory = WebSocketServerFactory(u"wss://localhost:9000", debug=False)
            WSfactory.protocol = self.MyServerProtocol
            WSfactory.noisy = False
            listenWS(WSfactory, contextFactory)
        else:
            # static HTTP serving
            reactor.listenTCP(Config.httpPort, staticFactory)


            # WS
            WSfactory = WebSocketServerFactory(u"ws://localhost:9000", debug=False)
            WSfactory.protocol = self.MyServerProtocol
            WSfactory.noisy = False
            listenWS(WSfactory)

        # no handlers because threads
        reactor.run(installSignalHandlers=0)
开发者ID:jkingsman,项目名称:Mockbox,代码行数:41,代码来源:Web.py

示例3: main

# 需要导入模块: from twisted.web.server import Site [as 别名]
# 或者: from twisted.web.server.Site import noisy [as 别名]
def main(pm):
    from sputnik.webserver.router.twisted.wamp import RouterFactory
    router_factory = RouterFactory()
    router_factory.router = SputnikRouter

    router_factory.authz_plugins = \
            pm.services.get("sputnik.webserver.plugins.authz", [])
    router_factory.schema_plugins = \
            pm.services.get("sputnik.webserver.plugins.schema", [])

    from sputnik.webserver.router.twisted.wamp import RouterSessionFactory
    session_factory = RouterSessionFactory(router_factory)
    session_factory.session = SputnikRouterSession

    authn_stack = [("ip.IPFilter", "requisite"),
                   ("anonymous.AnonymousLogin", "sufficient"),
                   ("cookie.CookieLogin", "sufficient"),
                   ("wampcra.WAMPCRALogin", "requisite"),
                   ("totp.TOTPVerification", "requisite")]
    session_factory.plugins = []
    for plugin_name, flag in authn_stack:
        path = "sputnik.webserver.plugins.authn." + plugin_name
        session_factory.plugins.append((pm.plugins[path], flag))

    rpc_plugins = pm.services.get("sputnik.webserver.plugins.rpc", [])
    feeds_plugins = pm.services.get("sputnik.webserver.plugins.feeds", [])
    svc_plugins = rpc_plugins + feeds_plugins
    for plugin in svc_plugins:
        component_session = plugin
        component_session.config.realm = u"sputnik"
        session_factory.add(component_session,
                plugin.plugin_path.decode("ascii"), u"trusted")

    uri = "ws://"
    if config.getboolean("webserver", "ssl"):
        uri = "wss://"

    address = config.get("webserver", "ws_address")
    port = config.getint("webserver", "ws_port")
    uri += "%s:%s/" % (address, port)

    from autobahn.twisted.websocket import WampWebSocketServerFactory
    transport_factory = WampWebSocketServerFactory(session_factory,
            uri, debug = False, debug_wamp = False)
    transport_factory.setProtocolOptions(failByDrop = False)
    watchdog(config.get("watchdog", "webserver"))

    from twisted.web.server import Site
    from autobahn.twisted.resource import WebSocketResource

    root = Root()
    ws_resource = WebSocketResource(transport_factory)
    rest_resource = pm.plugins['sputnik.webserver.rest.RESTProxy']
    root.putChild("ws", ws_resource)
    root.putChild("api", rest_resource)
    site = Site(root)
    site.noisy = False
    site.log = lambda _: None

    from twisted.internet.endpoints import serverFromString, quoteStringArgument
    if config.getboolean("webserver", "ssl"):
        key = config.get("webserver", "ssl_key")
        cert = config.get("webserver", "ssl_cert")
        cert_chain = config.get("webserver", "ssl_cert_chain")
        # TODO: Add dhparameters
        # See https://twistedmatrix.com/documents/14.0.0/core/howto/endpoints.html
        server = serverFromString(reactor, b"ssl:%d:privateKey=%s:certKey=%s:extraCertChain=%s:sslmethod=TLSv1_METHOD"
                                  % (port,
                                     quoteStringArgument(key),
                                     quoteStringArgument(cert),
                                     quoteStringArgument(cert_chain)))
    else:
        server = serverFromString(reactor, b"tcp:%d" % port)

    server.listen(site)
开发者ID:Mrkebubun,项目名称:sputnik,代码行数:77,代码来源:launch.py

示例4: MyBackendComponent

# 需要导入模块: from twisted.web.server import Site [as 别名]
# 或者: from twisted.web.server.Site import noisy [as 别名]
if __name__ == '__main__':

   log.startLogging(sys.stdout)

   router_factory = router.RouterFactory()
   session_factory = wamp.RouterSessionFactory(router_factory)

   component_config = types.ComponentConfig(realm = "realm1")
   component_session = MyBackendComponent(component_config)
   session_factory.add(component_session)

   ws_factory = websocket.WampWebSocketServerFactory(session_factory, \
                                                     debug = False, \
                                                     debug_wamp = False)
   ws_factory.startFactory()

   ws_resource = WebSocketResource(ws_factory)
   lp_resource = WampLongPollResource(session_factory, debug = True, debug_session_id = "kjmd3sBLOUnb3Fyr")

   root = File(".")
   root.putChild("ws", ws_resource)
   root.putChild("lp", lp_resource)

   web_factory = Site(root)
   web_factory.noisy = False

   server = serverFromString(reactor, "tcp:8080")
   server.listen(web_factory)

   reactor.run()
开发者ID:EricSchles,项目名称:AutobahnPython,代码行数:32,代码来源:server.py

示例5: WampWebSocketServerFactory

# 需要导入模块: from twisted.web.server import Site [as 别名]
# 或者: from twisted.web.server.Site import noisy [as 别名]
   transport_factory = WampWebSocketServerFactory(session_factory, args.wsurl, debug = False, debug_wamp = args.debug)
   transport_factory.setProtocolOptions(failByDrop = False)


   from twisted.web.server import Site
   from twisted.web.static import File
   from autobahn.twisted.resource import WebSocketResource

   ## we serve static files under "/" ..
   root = File(".")

   ## .. and our WebSocket server under "/ws"
   resource = WebSocketResource(transport_factory)
   root.putChild("ws", resource)

   ## run both under one Twisted Web Site
   site = Site(root)
   site.noisy = False
   site.log = lambda _: None


   ## start the WebSocket server from an endpoint
   ##
   server = serverFromString(reactor, args.websocket)
   server.listen(site)


   ## now enter the Twisted reactor loop
   ##
   reactor.run()
开发者ID:BanzaiMan,项目名称:AutobahnPython,代码行数:32,代码来源:server.py


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