##// END OF EJS Templates
Import some of the files from Select2 3.5.0 Javascript system....
Import some of the files from Select2 3.5.0 Javascript system. RhodeCode 2.2.5 used a version of Select2. Herein, we bring into Kallithea only a few files directly from Select2 3.5.0 (6ef7155) upstream, using the commands indicated below: (cd /tmp; \ git clone https://github.com/ivaynberg/select2.git; \ cd select2; \ git checkout 3.5.0 \ ) mkdir rhodecode/public/js/select2 cp -pa /tmp/select2/select2.{js,css,png} rhodecode/public/js/select2/ cp -pa /tmp/select2/select2x2.png rhodecode/public/js/select2/ cp -pa /tmp/select2/select2-spinner.gif rhodecode/public/js/select2/ hg add rhodecode/public/js/select2/

File last commit:

r2215:2c2bdaec codereview
r4128:bbbb013a 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