1import django.http 2from autotest_lib.frontend.tko import rpc_interface, graphing_utils 3from autotest_lib.frontend.tko import csv_encoder 4from autotest_lib.frontend.afe import rpc_handler, rpc_utils 5 6rpc_handler_obj = rpc_handler.RpcHandler((rpc_interface,), 7 document_module=rpc_interface) 8 9def handle_rpc(request): 10 return rpc_handler_obj.handle_rpc_request(request) 11 12 13def handle_jsonp_rpc(request): 14 return rpc_handler_obj.handle_jsonp_rpc_request(request) 15 16 17def handle_csv(request): 18 request_data = rpc_handler_obj.raw_request_data(request) 19 decoded_request = rpc_handler_obj.decode_request(request_data) 20 result = rpc_handler_obj.dispatch_request(decoded_request)['result'] 21 encoder = csv_encoder.encoder(decoded_request, result) 22 return encoder.encode() 23 24 25def rpc_documentation(request): 26 return rpc_handler_obj.get_rpc_documentation() 27 28 29def handle_plot(request): 30 id = request.GET['id'] 31 max_age = request.GET['max_age'] 32 return django.http.HttpResponse( 33 graphing_utils.handle_plot_request(id, max_age), mimetype='image/png') 34