Commit 1e7eb86a authored by Baptiste Jonglez's avatar Baptiste Jonglez
Browse files

Don't throw an exception when the graphite server is unreachable

parent 5ecc6d62
......@@ -2,9 +2,9 @@
from __future__ import unicode_literals
import os
from urllib2 import urlopen
import urllib2
from django.http import StreamingHttpResponse
from django.http import StreamingHttpResponse, HttpResponseServerError
from django.shortcuts import render_to_response, get_object_or_404
from django.views.generic.detail import DetailView
from django.views.generic.edit import UpdateView
......@@ -72,4 +72,7 @@ def get_graph(request, vpn_id, period="daily"):
"target=alias%%28scaleToSeconds%%28vpn1.%(login)s.uptxbytes%%2C1%%29%%2C%%20%%22Upload%%22%%29&" \
"title=VPN%%20Usage%%20%(login)s" % \
{ 'period': time_periods[period], 'login': vpn.login })
return StreamingHttpResponse(urlopen(graph_url), content_type="image/png")
return StreamingHttpResponse(urllib2.urlopen(graph_url), content_type="image/png")
except urllib2.URLError:
return HttpResponseServerError()
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment