aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYann Malet2011-09-11 05:16:47 +0200
committerYann Malet2011-09-11 05:16:47 +0200
commitd3649d340a9a7e20235fa63615830b9b0b7edbdd (patch)
tree5fe5ca865e05dae467eb14b0e096b15cbacf8ddf
parent83357d374f6741a5cf50da5c4f3f29934ed3281b (diff)
downloaddjango-debug-toolbar-d3649d340a9a7e20235fa63615830b9b0b7edbdd.tar.bz2
Fix the profiling panel when the line_profiler module is not available.
-rw-r--r--debug_toolbar/panels/profiling.py8
-rw-r--r--example/settings.py2
2 files changed, 6 insertions, 4 deletions
diff --git a/debug_toolbar/panels/profiling.py b/debug_toolbar/panels/profiling.py
index 623b27a..e57aa97 100644
--- a/debug_toolbar/panels/profiling.py
+++ b/debug_toolbar/panels/profiling.py
@@ -123,7 +123,8 @@ class FunctionCall(object):
return 16 * self.depth
def line_stats_text(self):
- if self._line_stats_text is None:
+ if (self._line_stats_text is None and
+ DJ_PROFILE_USE_LINE_PROFILER):
lstats = self.statobj.line_stats
if self.func in lstats.timings:
out = StringIO()
@@ -188,12 +189,13 @@ class ProfilingDebugPanel(DebugPanel):
func.has_subfuncs = False
if func.depth < max_depth:
for subfunc in func.subfuncs():
- if subfunc.stats[3] >= cum_time or (subfunc.func in self.stats.line_stats.timings):
+ if (subfunc.stats[3] >= cum_time or
+ (hasattr(self.stats, 'line_stats') and
+ (subfunc.func in self.stats.line_stats.timings))):
func.has_subfuncs = True
self.add_node(func_list, subfunc, max_depth, cum_time=cum_time)
def content(self):
- import ipdb; ipdb.set_trace()
root = FunctionCall(self.stats, self.stats.get_root_func(), depth=0)
func_list = []
diff --git a/example/settings.py b/example/settings.py
index a4d8ec4..b2b98ee 100644
--- a/example/settings.py
+++ b/example/settings.py
@@ -37,7 +37,7 @@ DEBUG_TOOLBAR_PANELS = (
'debug_toolbar.panels.timer.TimerDebugPanel',
'debug_toolbar.panels.settings_vars.SettingsVarsDebugPanel',
'debug_toolbar.panels.headers.HeaderDebugPanel',
-# 'debug_toolbar.panels.profiling.ProfilingDebugPanel',
+ 'debug_toolbar.panels.profiling.ProfilingDebugPanel',
'debug_toolbar.panels.request_vars.RequestVarsDebugPanel',
'debug_toolbar.panels.sql.SQLDebugPanel',
'debug_toolbar.panels.template.TemplateDebugPanel',