python类HTTPInternalServerError()的实例源码

views.py 文件源码 项目:pyramid_notebook 作者: websauna 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def notebook_proxy(request, username):
    """Renders a IPython Notebook frame wrapper.

    Starts or reattachs ot an existing Notebook session.
    """
    security_check(request, username)

    manager = get_notebook_manager(request)
    notebook_info = manager.get_context(username)

    if not notebook_info:
        raise HTTPInternalServerError("Apparently IPython Notebook daemon process is not running for {}".format(username))

    if not "http_port" in notebook_info:
        raise RuntimeError("Notebook terminated prematurely before managed to tell us its HTTP port")

    return proxy_it(request, notebook_info["http_port"])
jsonhelpers2.py 文件源码 项目:pyramid-zappa-api-boilerplate 作者: web-masons 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def __call__(self, info):
        """
        If a schema is present, replace value with output from schema.dump(..).
        """
        original_render = super().__call__(info)

        def schema_render(value, system):
            request = system.get('request')
            if (request is not None and isinstance(getattr(request, 'render_schema', None), Schema)):
                try:
                    value, errors = request.render_schema.dump(value)
                except Exception:
                    errors = True

                if errors:
                    raise HTTPInternalServerError(body="Serialization failed.")

            return original_render(value, system)

        return schema_render
test_pyramid.py 文件源码 项目:dd-trace-py 作者: DataDog 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def get_app(config):
    """ return a pyramid wsgi app with various urls. """

    def index(request):
        return Response('idx')

    def error(request):
        raise HTTPInternalServerError("oh no")

    def exception(request):
        1 / 0

    def json(request):
        return {'a': 1}

    def renderer(request):
        return render_to_response('template.pt', {'foo': 'bar'}, request=request)

    config.add_route('index', '/')
    config.add_route('error', '/error')
    config.add_route('exception', '/exception')
    config.add_route('json', '/json')
    config.add_route('renderer', '/renderer')
    config.add_view(index, route_name='index')
    config.add_view(error, route_name='error')
    config.add_view(exception, route_name='exception')
    config.add_view(json, route_name='json', renderer='json')
    config.add_view(renderer, route_name='renderer', renderer='template.pt')
    return config.make_wsgi_app()
views.py 文件源码 项目:de-visualization-wizard 作者: deleidos 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def topic_matching_service(request):
    parsed = urlparse(request.path_qs)
    question_words = parse_qsl(parsed.query)
    domain = request.matchdict.get('domain').replace(' ', '_')
    log.info('Topic matching on domain {}'.format(domain))

    tm = TopicMatcher(domain, request.registry.settings['MODELERLOCATION'], logger=log)
    data = tm.topic_matching(question_words)
    log.info('Topic matching completed')
    if not data:
        raise exc.HTTPInternalServerError(explanation="Topic matching failed. " +
                                          "A model has not been generated for the given taxonomy.")
    return data
views.py 文件源码 项目:de-visualization-wizard 作者: deleidos 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def data_set_ranking_service(request):
    domain = request.matchdict.get('domain')
    analytic_type = request.matchdict.get('analytic_type')
    interpretation = request.matchdict.get('interpretation')
    log.info('Ranking data sets with\ndomain: {}\nanalytic type: {}\ninterpretation: {}'.format(domain, analytic_type, interpretation))

    dm = DataMatcher(request.registry.settings['MODELERLOCATION'])
    ranking = dm.dataSetRanking(domain, analytic_type, interpretation)
    log.info('Data set ranking completed')
    log.info(ranking)
    if not ranking:
        raise exc.HTTPInternalServerError(explanation="There were no data sets found in the database.")
    return ranking
views.py 文件源码 项目:de-visualization-wizard 作者: deleidos 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def viz_ranking_service(request):
    log.info('Ranking vizes')
    parsed = urlparse(request.path_qs)
    question_analysis = parse_qs(parsed.query)

    dm = DataMatcher(request.registry.settings['MODELERLOCATION'])
    ranking = dm.vizRanking(question_analysis)
    log.info('Viz ranking completed')
    log.info(ranking)
    if not ranking[0]['viz_ranks']:
        raise exc.HTTPInternalServerError(explanation="There were no visualizations found in the database.")
    return ranking
resources.py 文件源码 项目:snovault 作者: ENCODE-DCC 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def __getitem__(self, name):
        try:
            resource = self.get(name)
        except KeyError:
            # Just in case we get an unexpected KeyError
            # FIXME: exception logging.
            raise HTTPInternalServerError('Traversal raised KeyError')
        if resource is None:
            raise KeyError(name)
        return resource
resources.py 文件源码 项目:snovault 作者: ENCODE-DCC 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def __getitem__(self, name):
        try:
            item = self.get(name)
        except KeyError:
            # Just in case we get an unexpected KeyError
            # FIXME: exception logging.
            raise HTTPInternalServerError('Traversal raised KeyError')
        if item is None:
            raise KeyError(name)
        return item


问题


面经


文章

微信
公众号

扫码关注公众号