|
@@ -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")
|
|
|
+ try:
|
|
|
+ return StreamingHttpResponse(urllib2.urlopen(graph_url), content_type="image/png")
|
|
|
+ except urllib2.URLError:
|
|
|
+ return HttpResponseServerError()
|