def html_report(request): """Static HTML reports with PNG charts""" try: snapshots = parse_snapshots(request) except ObjectDoesNotExist: return HttpResponse("Wrong or missing snapshot", status=400) plotter = Plotter() plotter.plot(snapshots) id_from_url = lambda url: url.split("/")[2].split(".")[0] urls = [(id_from_url(url), title, url) for title, url in plotter.urls] if urls: return render_to_response("report.jade", {"urls": urls}) else: return HttpResponse("No metrics found", status=400)
def html_report(request): """Static HTML reports with PNG charts""" try: snapshots = parse_snapshots(request) except ObjectDoesNotExist: return HttpResponse("Wrong or missing snapshot", status=400) labels = request.GET.getlist("label") if labels and len(labels) != len(snapshots): return HttpResponse("Snapshot and labels do not match", status=400) plotter = Plotter() images = plotter.plot(snapshots, custom_labels=labels) def id_from_url(url): return url.split("/")[-1].split(".")[0] urls = [(id_from_url(url), title, url) for title, url in images] if urls: return render_to_response("report.html", {"urls": urls}) else: return HttpResponse("No metrics found", status=400)