Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ARN
coin
Commits
1e7eb86a
Commit
1e7eb86a
authored
Apr 07, 2016
by
Baptiste Jonglez
Browse files
Don't throw an exception when the graphite server is unreachable
parent
5ecc6d62
Changes
1
Hide whitespace changes
Inline
Side-by-side
coin/vpn/views.py
View file @
1e7eb86a
...
...
@@ -2,9 +2,9 @@
from
__future__
import
unicode_literals
import
os
from
urllib2
import
url
open
import
url
lib2
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
()
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment