summaryrefslogtreecommitdiff
path: root/cherrypy/lib/profiler.py
diff options
context:
space:
mode:
authorSviatoslav Sydorenko <wk@sydorenko.org.ua>2016-09-08 13:02:02 +0300
committerSviatoslav Sydorenko <wk@sydorenko.org.ua>2016-09-08 13:02:02 +0300
commit879853b10f6e368b193de0031e31508eb80e6f04 (patch)
treee1547ad07829021659da71196612f53ed197ec99 /cherrypy/lib/profiler.py
parent907e8250674e0f4d531cda2ee97213976774f13a (diff)
downloadcherrypy-git-879853b10f6e368b193de0031e31508eb80e6f04.tar.gz
Fix E402 in lib/profiler
Diffstat (limited to 'cherrypy/lib/profiler.py')
-rw-r--r--cherrypy/lib/profiler.py27
1 files changed, 13 insertions, 14 deletions
diff --git a/cherrypy/lib/profiler.py b/cherrypy/lib/profiler.py
index 53cb83aa..adacb6a9 100644
--- a/cherrypy/lib/profiler.py
+++ b/cherrypy/lib/profiler.py
@@ -34,30 +34,31 @@ module from the command line, it will call ``serve()`` for you.
"""
import io
+import os
+import os.path
+import sys
+import warnings
import cherrypy
-def new_func_strip_path(func_name):
- """Make profiler output more readable by adding `__init__` modules' parents
- """
- filename, line, name = func_name
- if filename.endswith("__init__.py"):
- return os.path.basename(filename[:-12]) + filename[-12:], line, name
- return os.path.basename(filename), line, name
-
try:
import profile
import pstats
+
+ def new_func_strip_path(func_name):
+ """Make profiler output more readable by adding `__init__` modules' parents
+ """
+ filename, line, name = func_name
+ if filename.endswith("__init__.py"):
+ return os.path.basename(filename[:-12]) + filename[-12:], line, name
+ return os.path.basename(filename), line, name
+
pstats.func_strip_path = new_func_strip_path
except ImportError:
profile = None
pstats = None
-import os
-import os.path
-import sys
-import warnings
_count = 0
@@ -135,7 +136,6 @@ class Profiler(object):
@cherrypy.expose
def report(self, filename):
- import cherrypy
cherrypy.response.headers['Content-Type'] = 'text/plain'
return self.stats(filename)
@@ -206,7 +206,6 @@ def serve(path=None, port=8080):
"for details.")
warnings.warn(msg)
- import cherrypy
cherrypy.config.update({'server.socket_port': int(port),
'server.thread_pool': 10,
'environment': "production",