#NEWLINE# def ec2_error_response( request_id , code , message , status = 500 ) : #NEWLINE# #INDENT# 'Helper to construct an EC2 compatible error response.' #NEWLINE# LOG . debug ( 'EC2 error response: %(code)s: %(message)s' , { #NEWLINE# #INDENT# 'code' : request_id , #NEWLINE# 'message' : message , #NEWLINE# #UNINDENT# } ) #NEWLINE# resp = webob . Response ( ) #NEWLINE# resp . status = status #NEWLINE# resp . headers [ 'Content-Type' ] = 'text/xml' #NEWLINE# resp . body = ( '<?xml version="1.0"?>\n<Response><Errors><Error><Code>%s</Code><Message>%s</Message></Error></Errors><RequestID>%s</RequestID></Response>' % ( utils . xhtml_escape ( code ) , utils . xhtml_escape ( message ) , utils . xhtml_escape ( request_id ) ) ) . encode ( ) #NEWLINE# return resp