mozilla-services/circus-web — pull request #40 by lambdafu (2014-05-22 02:27:07+00:00)
Title: Fix draw_graph_div for display_status=True (e.g. statsd plugin).

Stock configuration with statsd plugin enabled breaks the webconsole (empty page after connect):

```
Traceback (most recent call last):
File "/home/marcus/semantics/projects/graunt/graunt-freimann/target/lib/python2.7/site-packages/circusweb/circushttpd.py", line 122, in render_template
return template.generate(**namespace)
File "/home/marcus/semantics/projects/graunt/graunt-freimann/target/lib/python2.7/site-packages/mako/template.py", line 443, in render
return runtime._render(self, self.callable_, args, data)
File "/home/marcus/semantics/projects/graunt/graunt-freimann/target/lib/python2.7/site-packages/mako/runtime.py", line 807, in _render
**_kwargs_for_callable(callable_, data))
File "/home/marcus/semantics/projects/graunt/graunt-freimann/target/lib/python2.7/site-packages/mako/runtime.py", line 839, in _render_context
_exec_template(inherit, lclcontext, args=args, kwargs=kwargs)
File "/home/marcus/semantics/projects/graunt/graunt-freimann/target/lib/python2.7/site-packages/mako/runtime.py", line 865, in _exec_template
callable_(context, *args, **kwargs)
File "/home/marcus/semantics/projects/graunt/graunt-freimann/target/lib/python2.7/site-packages/circusweb/templates/base.html", line 109, in render_body
${self.body()}
File "/home/marcus/semantics/projects/graunt/graunt-freimann/target/lib/python2.7/site-packages/circusweb/templates/index.html", line 105, in render_body
${draw_graph_div(plugin, plugin.split(':')[1].replace('-', '.'), True, endpoint=stat_endpoint)}
File "/home/marcus/semantics/projects/graunt/graunt-freimann/target/lib/python2.7/site-packages/circusweb/templates/index.html", line 1, in draw_graph_div
<%inherit file="base.html"/>
File "/home/marcus/semantics/projects/graunt/graunt-freimann/target/lib/python2.7/site-packages/circusweb/templates/index.html", line 68, in render_draw_graph_div

File "/home/marcus/semantics/projects/graunt/graunt-freimann/target/lib/python2.7/site-packages/circusweb/controller.py", line 129, in get_status
res = client.send_message('status', name=name)
AttributeError: 'NoneType' object has no attribute 'send_message'
```

Reason is that you got yourself confused about endpoint vs stat_endpoint. It's a bit unfortunate that the outer loop uses "endpoint" for what is actually the stat_endpoint, while the controller.py get_status call use endpoint for what it is. I cleaned up draw_graph_div, which is sufficient to make it work. For clarity, you might want to rename endpoint in the outer loop to stat_endpoint, too.