def populate_error_report(data):
<EOL>call_id, call_path = '<STR_LIT>', '<STR_LIT>'<EOL>if hasattr(stack.top, '<STR_LIT>'):<EOL><INDENT>call_id = stack.top.call_id<EOL><DEDENT>if hasattr(stack.top, '<STR_LIT>'):<EOL><INDENT>call_path = stack.top.call_path<EOL><DEDENT>data['<STR_LIT>'] = call_id<EOL>data['<STR_LIT>'] = call_path<EOL>data['<STR_LIT>'] = is_ec2_instance()<EOL>user_data = {<EOL>'<STR_LIT:id>': '<STR_LIT>',<EOL>'<STR_LIT>': <NUM_LIT:0>,<EOL>'<STR_LIT>': '<STR_LIT>',<EOL>}<EOL>if stack.top:<EOL><INDENT>user_data['<STR_LIT>'] = request.remote_addr<EOL>if '<STR_LIT>' in request.headers:<EOL><INDENT>user_data['<STR_LIT>'] = request.headers.get('<STR_LIT>', '<STR_LIT>')<EOL><DEDENT>if '<STR_LIT>' in request.headers:<EOL><INDENT>user_data['<STR_LIT>'] = request.headers.get('<STR_LIT>', '<STR_LIT>')<EOL><DEDENT><DEDENT>if hasattr(stack.top, '<STR_LIT>'):<EOL><INDENT>user_data['<STR_LIT>'] = <NUM_LIT:1><EOL>user_data['<STR_LIT:id>'] = stack.top.current_user.get('<STR_LIT>', '<STR_LIT>')<EOL>for k in ('<STR_LIT:name>', '<STR_LIT:email>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>'):<EOL><INDENT>v = stack.top.current_user.get(k, None)<EOL>if v:<EOL><INDENT>user_data[k] = v<EOL><DEDENT><DEDENT><DEDENT>data['<STR_LIT:user>'] = user_data<EOL>if ApiPool().current_server_api:<EOL><INDENT>server = request.base_url<EOL>server = server.replace('<STR_LIT>', '<STR_LIT>')<EOL>server = server.replace('<STR_LIT>', '<STR_LIT>')<EOL>server = server.split('<STR_LIT:/>')[<NUM_LIT:0>]<EOL>parts = server.split('<STR_LIT::>')<EOL>fqdn = parts[<NUM_LIT:0>]<EOL>port = parts[<NUM_LIT:1>] if len(parts) == <NUM_LIT:2> else '<STR_LIT>'<EOL>data['<STR_LIT>'] = {<EOL>'<STR_LIT>': fqdn,<EOL>'<STR_LIT:port>': port,<EOL>'<STR_LIT>': ApiPool().current_server_name,<EOL>'<STR_LIT>': ApiPool().current_server_api.get_version(),<EOL>}<EOL>data['<STR_LIT>'] = {<EOL>'<STR_LIT:id>': "<STR_LIT>" % (ApiPool().current_server_name, request.method, request.path),<EOL>'<STR_LIT:url>': request.url,<EOL>'<STR_LIT>': request.base_url,<EOL>'<STR_LIT:path>': request.path,<EOL>'<STR_LIT>': request.method<EOL>}<EOL><DEDENT>
Add generic stats to the error report