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


Python Site.displayTracebacks方法代码示例

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


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

示例1: setup

# 需要导入模块: from twisted.web.server import Site [as 别名]
# 或者: from twisted.web.server.Site import displayTracebacks [as 别名]
def setup(args=None):
    """
    This is the main setup function to establish the TCP listening logic for
    the API server. This code also takes into account development or unit test mode.
    """

    # Setup API server
    api = ParadropAPIServer(reactor)
    api.putChild('internal', Base(apiinternal, allowNone=True))
    site = Site(api, timeout=None)

    # Development mode
    if(args and args.development):
        thePort = settings.PDFCD_PORT + 10000
        out.info('Using DEVELOPMENT variables')
        # Disable sending the error traceback to the client
        site.displayTracebacks = True
    elif(args and args.unittest):
        thePort = settings.PDFCD_PORT + 20000
        out.info('Running under unittest mode')
        site.displayTracebacks = True
    else:
        thePort = settings.PDFCD_PORT
        site.displayTracebacks = False
        initializeSystem()

    # Setup the port we listen on
    reactor.listenTCP(thePort, site)

    # Never return from here
    reactor.run()
开发者ID:SejalChauhan,项目名称:Paradrop,代码行数:33,代码来源:server.py

示例2: run

# 需要导入模块: from twisted.web.server import Site [as 别名]
# 或者: from twisted.web.server.Site import displayTracebacks [as 别名]
def run(port, sqlite_conn, index_html, static_root):
    #--------------------------------------------------------------------------
    # log to stdout
    #--------------------------------------------------------------------------
    from twisted.python import log
    import sys
    log.startLogging(sys.stdout)
    
    #--------------------------------------------------------------------------
    # database
    #--------------------------------------------------------------------------
    from twisted.enterprise import adbapi
    pool = adbapi.ConnectionPool('sqlite3', sqlite_conn, check_same_thread=False,
                                 cp_min=1, cp_max=1)
    data_model = DataModel(pool)
    
    #--------------------------------------------------------------------------
    # url/resource mapping
    #--------------------------------------------------------------------------
    root = Resource()
    root.putChild('', File(index_html))
    root.putChild('static', File(static_root))
    root.putChild('todos', Todos(data_model))
    
    #--------------------------------------------------------------------------
    # serve it
    #--------------------------------------------------------------------------
    from twisted.internet import reactor
    from twisted.web.server import Site
    site = Site(root)
    site.displayTracebacks = False
    reactor.listenTCP(port, site)
    reactor.run()  
开发者ID:phantomxc,项目名称:TodoPy,代码行数:35,代码来源:main.py

示例3: Service

# 需要导入模块: from twisted.web.server import Site [as 别名]
# 或者: from twisted.web.server.Site import displayTracebacks [as 别名]
def Service(options):
    consumer = QueueConsumer(
        consumer_queue=ns.MASTER_QUEUE,
        pool_size=ns.MAX_MESSAGES,
        spec_path=ns.SPEC_PATH,
        vhost=ns.RABBITMQ_VHOST,
        username=ns.RABBITMQ_USERNAME,
        password=ns.RABBITMQ_PASSWORD,
        host=ns.RABBITMQ_HOST,
        port=ns.RABBITMQ_PORT
        )

    publisher = QueuePublisher(
        declare_strategy=1,
        spec_path=ns.SPEC_PATH,
        vhost=ns.RABBITMQ_VHOST,
        username=ns.RABBITMQ_USERNAME,
        password=ns.RABBITMQ_PASSWORD,
        host=ns.RABBITMQ_HOST,
        port=ns.RABBITMQ_PORT
        )
    resource = MasterResource()
    resource.init(consumer, publisher)
    site = Site(resource)
    site.displayTracebacks = ns.DEBUG
    return internet.TCPServer(int(options['port']), site, \
        interface=options['iface'])
开发者ID:yunmanger1,项目名称:task-mapreduce,代码行数:29,代码来源:server_master.py

示例4: _create_web_factory

# 需要导入模块: from twisted.web.server import Site [as 别名]
# 或者: from twisted.web.server.Site import displayTracebacks [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

示例5: make_site

# 需要导入模块: from twisted.web.server import Site [as 别名]
# 或者: from twisted.web.server.Site import displayTracebacks [as 别名]
def make_site(resource, site_logs_path):
    site = Site(
        resource,
        logPath=site_logs_path.path,
        logFormatter=_LogFormatter(datetime.utcnow).json_access_log,
    )
    site.displayTracebacks = False
    return site
开发者ID:LeastAuthority,项目名称:leastauthority.com,代码行数:10,代码来源:__init__.py

示例6: site

# 需要导入模块: from twisted.web.server import Site [as 别名]
# 或者: from twisted.web.server.Site import displayTracebacks [as 别名]
    def site(self, displayTracebacks=True, **kwargs):
        """
        A :twisted:`web.server.Site` that will serve me.

        """

        site = Site(self.app.resource(), **kwargs)
        site.displayTracebacks = displayTracebacks
        return site
开发者ID:Julian,项目名称:PiPy,代码行数:11,代码来源:core.py

示例7: get_site

# 需要导入模块: from twisted.web.server import Site [as 别名]
# 或者: from twisted.web.server.Site import displayTracebacks [as 别名]
def get_site(resource, logging=False):
    """
    :param resource: A :class:`twisted.web.resource.Resource` object.
    :return: a :class:`Site` that can be run
    """
    site = Site(resource)
    site.displayTracebacks = False
    site.requestFactory = MimicLoggingRequest if logging else MimicRequest
    return site
开发者ID:derwolfe,项目名称:mimic,代码行数:11,代码来源:resource.py

示例8: makeService

# 需要导入模块: from twisted.web.server import Site [as 别名]
# 或者: from twisted.web.server.Site import displayTracebacks [as 别名]
def makeService(config):
    """
    Set up the otter-api service.
    """
    set_config_data(dict(config))

    if not config_value('mock'):
        seed_endpoints = [
            clientFromString(reactor, str(host))
            for host in config_value('cassandra.seed_hosts')]

        cassandra_cluster = LoggingCQLClient(RoundRobinCassandraCluster(
            seed_endpoints,
            config_value('cassandra.keyspace')), log.bind(system='otter.silverberg'))

        set_store(CassScalingGroupCollection(cassandra_cluster))

    bobby_url = config_value('bobby_url')
    if bobby_url is not None:
        set_bobby(BobbyClient(bobby_url))

    cache_ttl = config_value('identity.cache_ttl')

    if cache_ttl is None:
        # FIXME: Pick an arbitrary cache ttl value based on absolutely no
        # science.
        cache_ttl = 300

    authenticator = CachingAuthenticator(
        reactor,
        ImpersonatingAuthenticator(
            config_value('identity.username'),
            config_value('identity.password'),
            config_value('identity.url'),
            config_value('identity.admin_url')),
        cache_ttl)

    supervisor = Supervisor(authenticator.authenticate_tenant, coiterate)

    set_supervisor(supervisor)

    s = MultiService()

    site = Site(root)
    site.displayTracebacks = False

    api_service = service(str(config_value('port')), site)
    api_service.setServiceParent(s)

    if config_value('scheduler') and not config_value('mock'):
        scheduler_service = SchedulerService(int(config_value('scheduler.batchsize')),
                                             int(config_value('scheduler.interval')),
                                             cassandra_cluster)
        scheduler_service.setServiceParent(s)

    return s
开发者ID:michael-mcgrail-rackspace,项目名称:otter,代码行数:58,代码来源:api.py

示例9: makeService

# 需要导入模块: from twisted.web.server import Site [as 别名]
# 或者: from twisted.web.server.Site import displayTracebacks [as 别名]
def makeService(config):
    """
    Set up the otter-api service.
    """
    set_config_data(dict(config))

    # Try to configure graylog and airbrake.

    if config_value('graylog'):
        if GraylogUDPPublisher is not None:
            log.addObserver(
                make_observer_chain(
                    GraylogUDPPublisher(**config_value('graylog')), False))
        else:
            warnings.warn("There is a configuration option for Graylog, but "
                          "txgraylog is not installed.")

    if config_value('airbrake'):
        if AirbrakeLogObserver is not None:
            airbrake = AirbrakeLogObserver(
                config_value('airbrake.api_key'),
                config_value('environment'),
                use_ssl=True
            )

            airbrake.start()
        else:
            warnings.warn("There is a configuration option for Airbrake, but "
                          "txairbrake is not installed.")

    if not config_value('mock'):
        seed_endpoints = [
            clientFromString(reactor, str(host))
            for host in config_value('cassandra.seed_hosts')]

        cassandra_cluster = RoundRobinCassandraCluster(
            seed_endpoints,
            config_value('cassandra.keyspace'))

        set_store(CassScalingGroupCollection(cassandra_cluster))

    s = MultiService()

    site = Site(root)
    site.displayTracebacks = False

    api_service = service(str(config_value('port')), site)
    api_service.setServiceParent(s)

    if config_value('scheduler'):
        scheduler_service = SchedulerService(int(config_value('scheduler.batchsize')),
                                             int(config_value('scheduler.interval')),
                                             cassandra_cluster)
        scheduler_service.setServiceParent(s)

    return s
开发者ID:apurvvkumaria,项目名称:otter,代码行数:58,代码来源:api.py

示例10: secureSite

# 需要导入模块: from twisted.web.server import Site [as 别名]
# 或者: from twisted.web.server.Site import displayTracebacks [as 别名]
def secureSite(_environ=environ):
    """Builds the secure (HTTPS, port 443) site.

    """
    root = File(_environ["STATIC_PATH"])
    root.putChild("subscribe", SubscribeResource("[email protected]"))

    site = Site(root)
    site.displayTracebacks = False
    site.requestFactory = _withHSTS(site.requestFactory)
    return site
开发者ID:crypto101,项目名称:website,代码行数:13,代码来源:web.py

示例11: makeService

# 需要导入模块: from twisted.web.server import Site [as 别名]
# 或者: from twisted.web.server.Site import displayTracebacks [as 别名]
    def makeService(self, options):
        store = Store(options['dbdir'])
        siteService = IService(store)

        site = Site(
            RootResource(store=store,
                         trackingID=options['tracking-id']))
        site.displayTracebacks = not options['notracebacks']
        siteService.addService(
            strports.service(options['port'], site, reactor=reactor))
        return siteService
开发者ID:jonathanj,项目名称:Codetip,代码行数:13,代码来源:codetip_service.py

示例12: makeService

# 需要导入模块: from twisted.web.server import Site [as 别名]
# 或者: from twisted.web.server.Site import displayTracebacks [as 别名]
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,代码行数:13,代码来源:tap.py

示例13: make_site

# 需要导入模块: from twisted.web.server import Site [as 别名]
# 或者: from twisted.web.server.Site import displayTracebacks [as 别名]
def make_site(basefp, config):
    resource = JinjaHandler('index.html')
    resource.putChild('static', File('content/static'))
    resource.putChild('blog', File('content/blog'))
    resource.putChild('collect-email', CollectEmailHandler(basefp))
    resource.putChild('signup', Redirect("/"))
    resource.putChild('submit-subscription', SubmitSubscriptionHandler(basefp))
    resource.putChild('support', Redirect("https://leastauthority.zendesk.com/home"))

    site = Site(resource, logPath=basefp.child('sitelogs').path)
    site.displayTracebacks = True
    return site
开发者ID:BenKoerber,项目名称:leastauthority.com,代码行数:14,代码来源:__init__.py

示例14: make_site

# 需要导入模块: from twisted.web.server import Site [as 别名]
# 或者: from twisted.web.server.Site import displayTracebacks [as 别名]
def make_site(basefp, config):
    resource = JinjaHandler('index.html')
    resource.putChild('static', File('content/static'))
    resource.putChild('blog', File('content/blog'))
    resource.putChild('collect-email', CollectEmailHandler(basefp, config.products))
    resource.putChild('signup', SignupHandler(config.products))
    resource.putChild('devpay-complete', DevPayPurchaseHandler(basefp, config.products))
    resource.putChild('activation-request', ActivationRequestHandler(basefp, config.products))
    resource.putChild('support', Redirect("https://leastauthority.zendesk.com/home"))

    site = Site(resource, logPath=basefp.child('sitelogs').path)
    site.displayTracebacks = False
    return site
开发者ID:ArtRichards,项目名称:leastauthority.com,代码行数:15,代码来源:__init__.py

示例15: startService

# 需要导入模块: from twisted.web.server import Site [as 别名]
# 或者: from twisted.web.server.Site import displayTracebacks [as 别名]
 def startService(self):
     if self.port_s is not None:
         endpoint = serverFromString(reactor, self.port_s)
         d = endpoint.listen(self.site)
         d.addCallback(self.register_port, 'app')
     if self.auth_info_endpoint_s is not None:
         authInfoApp = AuthInfoApp()
         self.authInfoApp = authInfoApp
         authInfoSite = Site(authInfoApp.app.resource())
         authInfoSite.displayTracebacks = self.site.displayTracebacks
         endpoint = serverFromString(reactor, self.auth_info_endpoint_s)
         d2 = endpoint.listen(authInfoSite)
         d2.addCallback(self.register_port, 'authInfoSite')
开发者ID:cwaldbieser,项目名称:txcasproxy,代码行数:15,代码来源:service.py


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