Scott Baker | c7325a4 | 2014-05-30 16:06:46 -0700 | [diff] [blame] | 1 | from view_common import * |
| 2 | |
| 3 | class SimulatorView(View): |
| 4 | def get(self, request, **kwargs): |
| 5 | sim = json.loads(file("/tmp/simulator.json","r").read()) |
| 6 | text = "<html><head></head><body>" |
| 7 | text += "Iteration: %d<br>" % sim["iteration"] |
| 8 | text += "Elapsed since report %d<br><br>" % sim["elapsed_since_report"] |
| 9 | text += "<table border=1>" |
| 10 | text += "<tr><th>site</th><th>trend</th><th>weight</th><th>bytes_sent</th><th>hot</th></tr>" |
| 11 | for site in sim["site_load"].values(): |
| 12 | text += "<tr>" |
| 13 | text += "<td>%s</td><td>%0.2f</td><td>%0.2f</td><td>%d</td><td>%0.2f</td>" % \ |
| 14 | (site["name"], site["trend"], site["weight"], site["bytes_sent"], site["load_frac"]) |
| 15 | text += "</tr>" |
| 16 | text += "</table>" |
| 17 | text += "</body></html>" |
| 18 | return HttpResponse(text) |