Handles the response from the SAR service call

        :param dict response: the response dictionary from the app repo
        :param string application_id: the ApplicationId
        :param string template_id: the unique TemplateId for this application
480233
def _handle_get_cfn_template_response(self, response, application_id, template_id):
        
        status = response['Status']
        if status != "ACTIVE":
            # Other options are PREPARING and EXPIRED.
            if status == 'EXPIRED':
                message = ("Template for {} with id {} returned status: {}. Cannot access an expired "
                           "template.".format(application_id, template_id, status))
                raise InvalidResourceException(application_id, message)
            self._in_progress_templates.append((application_id, template_id))
677987
def render_template(request, app, template_name, context=None, subdir="templates", def_name=None):
    '''
    
    '''
    return get_template(app, template_name, subdir).render(context, request, def_name)
492368
def fancy_error_template_middleware(app):
    
    def application(environ, start_response):
        try:
            return app(environ, start_response)
        except Exception as exc:
            sio = StringIO()
            traceback.print_exc(file=sio)
            sio.seek(0)
            response =  Response(
                status=500,
                body=render_error_page(500, exc, traceback=sio.read()),
                content_type="text/html"
            )
            return response(environ, start_response)

    return application
382754
protected void handleAppendResponse(RaftMemberContext member, AppendRequest request, AppendResponse response, long timestamp) {
    if (response.status() == RaftResponse.Status.OK) {
      handleAppendResponseOk(member, request, response);
    } else {
      handleAppendResponseError(member, request, response);
    }
  }
143331
def get_async_response(response_id):
    
    response = DYNAMODB_CLIENT.get_item(
        TableName=ASYNC_RESPONSE_TABLE,
        Key={'id': {'S': str(response_id)}}
    )
    if 'Item' not in response:
        return None

    return {
        'status': response['Item']['async_status']['S'],
        'response': json.loads(response['Item']['async_response']['S']),
    }
733983
def respond(template, context={}, request=None, **kwargs):
    ""
    from django.http import HttpResponse
    from django.template import RequestContext
    from django.template.loader import render_to_string    

    if request:
        default = context_processors.default(request)
        default.update(context)
    else:
        default = context.copy()
    
    rendered = render_to_string(template, default, context_instance=request and RequestContext(request) or None)
    return HttpResponse(rendered, **kwargs)
302224
async def inject_request_id(app, handler):
    

    async def trace_request(request):
        request['x-request-id'] = \
            request.headers.get('x-request-id') or str(uuid.uuid4())
        return await handler(request)

    return trace_request
1268152
def _got_response(self, msg):
        '''
            
        '''

        #logger.debug("MSG: %r" % msg)

        resp_id = msg.get('id', None)

        if resp_id is None:
            # subscription traffic comes with method set, but no req id.
            method = msg.get('method', None)
            if not method:
                logger.error("Incoming server message had no ID nor method in it", msg)
                return

            # not obvious, but result is on params, not result, for subscriptions
            result = msg.get('params', None)

            logger.debug("Traffic on subscription: %s" % method)

            subs = self.subscriptions.get(method)
            for q in subs:
                self.loop.create_task(q.put(result))

            return

        assert 'method' not in msg
        result = msg.get('result')

        # fetch and forget about the request
        inf = self.inflight.pop(resp_id) 
        if not inf:
            logger.error("Incoming server message had unknown ID in it: %s" % resp_id)
            return

        # it's a future which is done now
        req, rv = inf

        if 'error' in msg:
            err = msg['error']
            
            logger.info("Error response: '%s'" % err)
            rv.set_exception(ElectrumErrorResponse(err, req))

        else:
            rv.set_result(result)
108418
void handleResponse(ByteBuf response) {
    long requestId = response.readLong();
    byte status = response.readByte();
    switch (status) {
      case SUCCESS:
        try {
          handleResponseSuccess(requestId, readResponse(response));
        } catch (SerializationException e) {
          handleResponseFailure(requestId, e);
        }
        break;
      case FAILURE:
        try {
          handleResponseFailure(requestId, readError(response));
        } catch (SerializationException e) {
          handleResponseFailure(requestId, e);
        }
        break;
    }
    response.release();
  }
118940
public Observable<Map<String, String>> listEndpointsAsync(UUID appId) {
        return listEndpointsWithServiceResponseAsync(appId).map(new Func1<ServiceResponse<Map<String, String>>, Map<String, String>>() {
            @Override
            public Map<String, String> call(ServiceResponse<Map<String, String>> response) {
                return response.body();
            }
        });
    }
1129826
def handle_response(response)
      type, msgid, error, result = response
      if observable = @requests[msgid]
        @requests[msgid].set_response(result, error)
      else
        warn "unknown response with id=#{msgid}"
      end
    end
1051742
@GetMapping(path = "/yadis.xml")
    public void yadis(final HttpServletResponse response) throws Exception {
        val template = this.resourceLoader.getResource("classpath:/yadis.template");
        try (val writer = new StringWriter()) {
            IOUtils.copy(template.getInputStream(), writer, StandardCharsets.UTF_8);
            val yadis = writer.toString().replace("$casLoginUrl", casProperties.getServer().getLoginUrl());
            response.setContentType("application/xrds+xml");
            val respWriter = response.getWriter();
            respWriter.write(yadis);
            respWriter.flush();
        }
    }
629698
def do_response(self, response_args=None, request=None, **kwargs):
        

        links = [Link(href=h, rel=OIC_ISSUER) for h in kwargs['hrefs']]

        _response = JRD(subject=kwargs['subject'], links=links)

        info = {
            'response': _response.to_json(),
            'http_headers': [('Content-type', 'application/json')]
        }

        return info
90932
protected void handleInvocationResponse (int reqId, int methodId, Object[] args)
    {
        // look up the invocation marshaller registered for that response
        ListenerMarshaller listener = _listeners.remove(reqId);
        if (listener == null) {
            log.warning("Received invocation response for which we have no registered listener. " +
                        "It is possible that this listener was flushed because the response did " +
                        "not arrive within " + _listenerMaxAge + " milliseconds.",
                        "reqId", reqId, "methId", methodId, "args", args);
            return;
        }

//         log.info("Dispatching invocation response", "listener", listener,
//                  "methId", methodId, "args", args);

        // dispatch the response
        try {
            listener.dispatchResponse(methodId, args);
        } catch (Throwable t) {
            log.warning("Invocation response listener choked", "listener", listener,
                        "methId", methodId, "args", args, t);
        }

        // flush expired listeners periodically
        long now = System.currentTimeMillis();
        if (now - _lastFlushTime > LISTENER_FLUSH_INTERVAL) {
            _lastFlushTime = now;
            flushListeners(now);
        }
    }
1193710
def handler_view(self, request, resource_name, ids=None):
        
        signal_request.send(sender=self, request=request)
        time_start = time.time()
        self.update_urls(request, resource_name=resource_name, ids=ids)
        resource = self.resource_map[resource_name]

        allowed_http_methods = resource.Meta.allowed_methods
        if request.method not in allowed_http_methods:
            response = HttpResponseNotAllowed(
                permitted_methods=allowed_http_methods)
            signal_response.send(
                sender=self, request=request, response=response,
                duration=time.time() - time_start)
            return response

        if resource.Meta.authenticators and not (
                request.method == "GET" and
                resource.Meta.disable_get_authentication):
            user = resource.authenticate(request)
            if user is None or not user.is_authenticated():
                response = HttpResponse("Not Authenticated", status=401)
                signal_response.send(
                    sender=self, request=request, response=response,
                    duration=time.time() - time_start)
                return response

        kwargs = dict(request=request)
        if ids is not None:
            kwargs['ids'] = ids.split(",")

        try:
            if request.method == "GET":
                response = self.handler_view_get(resource, **kwargs)
            elif request.method == "POST":
                response = self.handler_view_post(resource, **kwargs)
            elif request.method == "PUT":
                response = self.handler_view_put(resource, **kwargs)
            elif request.method == "DELETE":
                response = self.handler_view_delete(resource, **kwargs)
        except JSONAPIError as e:
            response = HttpResponse(
                json.dumps({"errors": [e.data]}, cls=DatetimeDecimalEncoder),
                content_type=self.CONTENT_TYPE, status=e.status)

        signal_response.send(sender=self, request=request, response=response,
                             duration=time.time() - time_start)
        return response
632670
def displayResponse(request, openid_response):
    
    s = getServer(request)

    # Encode the response into something that is renderable.
    try:
        webresponse = s.encodeResponse(openid_response)
    except EncodingError as why:
        # If it couldn't be encoded, display an error.
        text = why.response.encodeToKVForm()
        return render_to_response(
            'server/endpoint.html', {'error': cgi.escape(text)},
            context_instance=RequestContext(request))

    # Construct the appropriate django framework response.
    r = http.HttpResponse(webresponse.body)
    r.status_code = webresponse.code

    for header, value in webresponse.headers.items():
        r[header] = value

    return r
177225
def _handle_response(self, msg_id, result=None, error=None):
        """"""
        request_future = self._server_request_futures.pop(msg_id, None)

        if not request_future:
            log.warn("Received response to unknown message id %s", msg_id)
            return

        if error is not None:
            log.debug("Received error response to message %s: %s", msg_id, error)
            request_future.set_exception(JsonRpcException.from_dict(error))

        log.debug("Received result for message %s: %s", msg_id, result)
        request_future.set_result(result)