##// END OF EJS Templates
Add mousetrap.js file from Mousetrap 1.4.5, under the Apache license....
Add mousetrap.js file from Mousetrap 1.4.5, under the Apache license. The file was download and verified via these commands: $ git clone https://github.com/ccampbell/mousetrap.git $ cd mousetrap; git checkout 1.4.5 The file in that repository named mousetrap.js is exactly the same one that appeared in RhodeCode 2.2.5 in changeset c8d3c0d61d95. The mousetrap.js states clearly that it is licensed under Apache-2.0.

File last commit:

r2215:2c2bdaec codereview
r4126:158ef336 rhodecode-2.2.5-gpl
Show More
profiler.py
60 lines | 1.6 KiB | text/x-python | PythonLexer
renamed project to rhodecode
r547 from __future__ import with_statement
code-review initial
r2215 import gc
import objgraph
renamed project to rhodecode
r547 import cProfile
import pstats
import cgi
import pprint
import threading
from StringIO import StringIO
pep8ify
r1307
renamed project to rhodecode
r547 class ProfilingMiddleware(object):
def __init__(self, app):
self.lock = threading.Lock()
self.app = app
source code cleanup: remove trailing white space, normalize file endings
r1203
renamed project to rhodecode
r547 def __call__(self, environ, start_response):
with self.lock:
profiler = cProfile.Profile()
pep8ify
r1307
renamed project to rhodecode
r547 def run_app(*a, **kw):
self.response = self.app(environ, start_response)
profiler.runcall(run_app, environ, start_response)
profiler.snapshot_stats()
stats = pstats.Stats(profiler)
code-review initial
r2215 stats.sort_stats('calls') #cummulative
renamed project to rhodecode
r547
# Redirect output
out = StringIO()
stats.stream = out
stats.print_stats()
resp = ''.join(self.response)
# Lets at least only put this on html-like responses.
if resp.strip().startswith('<'):
## The profiling info is just appended to the response.
## Browsers don't mind this.
pep8ify
r1307 resp += ('<pre style="text-align:left; '
'border-top: 4px dashed red; padding: 1em;">')
renamed project to rhodecode
r547 resp += cgi.escape(out.getvalue(), True)
source code cleanup: remove trailing white space, normalize file endings
r1203
code-review initial
r2215 ct = objgraph.show_most_common_types()
print ct
resp += ct if ct else '---'
renamed project to rhodecode
r547 output = StringIO()
pprint.pprint(environ, output, depth=3)
source code cleanup: remove trailing white space, normalize file endings
r1203
renamed project to rhodecode
r547 resp += cgi.escape(output.getvalue(), True)
resp += '</pre>'
source code cleanup: remove trailing white space, normalize file endings
r1203
renamed project to rhodecode
r547 return resp