-
-
Notifications
You must be signed in to change notification settings - Fork 337
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a simple view in request detail context allowing to get python …
…profile (#295) * Added new url pattern Added new url pattern to support python profile from request * Added new request menu Adde new request menu to support python profile from request * Added new template Added new template to support python profile from request * Added new view Added new view to support python profile from request
- Loading branch information
Showing
4 changed files
with
135 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
{% extends "silk/base/detail_base.html" %} | ||
{% load silk_filters %} | ||
{% load silk_nav %} | ||
{% load silk_inclusion %} | ||
{% load staticfiles %} | ||
|
||
{% block js %} | ||
<script type="text/javascript" src="{% static 'silk/lib/viz-lite.js' %}"></script> | ||
<script type="text/javascript" src="{% static 'silk/lib/svg-pan-zoom.min.js' %}"></script> | ||
{{ block.super }} | ||
{% endblock %} | ||
|
||
{% block style %} | ||
{{ block.super }} | ||
<link rel="stylesheet" href="{% static 'silk/css/summary.css' %}"> | ||
<style> | ||
#query-info-div { | ||
margin-top: 15px; | ||
} | ||
|
||
#query-info-div .timestamp-div { | ||
font-size: 13px; | ||
|
||
} | ||
|
||
#pyprofile-div { | ||
display: block; | ||
margin: auto; | ||
width: 960px; | ||
} | ||
|
||
.pyprofile { | ||
text-align: left; | ||
} | ||
|
||
a { | ||
color: #45ADA8; | ||
} | ||
|
||
a:visited { | ||
color: #45ADA8; | ||
} | ||
|
||
a:hover { | ||
color: #547980; | ||
} | ||
|
||
a:active { | ||
color: #594F4F; | ||
} | ||
|
||
#graph-div { | ||
padding: 25px; | ||
background-color: white; | ||
display: block; | ||
margin-left: auto; | ||
margin-right: auto; | ||
margin-top: 25px; | ||
width: 960px; | ||
text-align: center; | ||
} | ||
|
||
#percent { | ||
width: 20px; | ||
} | ||
|
||
svg { | ||
display: block; | ||
} | ||
|
||
</style> | ||
{% endblock %} | ||
|
||
{% block menu %} | ||
{% request_menu request silk_request %} | ||
{% endblock %} | ||
|
||
|
||
{% block data %} | ||
<div class="wrapper"> | ||
<div id="query-div"> | ||
{% if silk_request.pyprofile %} | ||
<div id="pyprofile-div"> | ||
<div class="heading"> | ||
<div class="inner-heading">CProfile</div> | ||
</div> | ||
<div class="description"> | ||
The below is a dump from the cPython profiler. | ||
</div> | ||
{% if silk_request.prof_file %} | ||
Click <a href="{% url 'silk:request_profile_download' request_id=silk_request.pk %}">here</a> to download profile. | ||
{% endif %} | ||
<pre class="pyprofile">{{ silk_request.pyprofile }}</pre> | ||
{% endif %} | ||
</div> | ||
</div> | ||
</div> | ||
|
||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
from django.shortcuts import render | ||
from django.utils.decorators import method_decorator | ||
from django.views.generic import View | ||
from silk.auth import login_possibly_required, permissions_possibly_required | ||
from silk.models import Profile | ||
from silk.views.code import _code_context, _code_context_from_request | ||
from silk.models import Request | ||
|
||
|
||
class CProfileView(View): | ||
|
||
@method_decorator(login_possibly_required) | ||
@method_decorator(permissions_possibly_required) | ||
def get(self, request, *_, **kwargs): | ||
request_id = kwargs['request_id'] | ||
silk_request = Request.objects.get(pk=request_id) | ||
context = { | ||
'silk_request': silk_request, | ||
'request': request} | ||
|
||
return render(request, 'silk/cprofile.html', context) |