##// END OF EJS Templates
hg: Redirect Mercurial stdout/stderr to logging when running as WSGI...
hg: Redirect Mercurial stdout/stderr to logging when running as WSGI Any "console" output from Mercurial when Kallithea is running from WSGI should end up in Kallithea's logs. That seems like a nice general feature. This will however also solve another rare but more critical problem: Mercurial is writing to sys.stdout / sys.stderr, using several layers of wrapping. Since Mercurial 5.5 (with https://repo.mercurial-scm.org/hg/rev/8e04607023e5 ), all writes are given a memoryview. Apache httpd mod_wsgi is invoking the WSGI with a custom mod_wsgi.Log injected in sys.stdout / sys.stderr . This logger can however not handle memoryview - https://github.com/GrahamDumpleton/mod_wsgi/issues/863 .

File last commit:

r8549:f8971422 default
r8795:fe050a93 stable
Show More
source_format.py
24 lines | 701 B | text/x-python | PythonLexer
Mads Kiilerich
scripts: introduce source_format.py to fix up the module name in file headers
r8549 #!/usr/bin/env python3
# hg files 'set:!binary()&grep("^#!.*python")' 'set:**.py' | xargs scripts/source_format.py
import re
import sys
filenames = sys.argv[1:]
for fn in filenames:
with open(fn) as f:
org_content = f.read()
mod_name = fn[:-3] if fn.endswith('.py') else fn
mod_name = mod_name[:-9] if mod_name.endswith('/__init__') else mod_name
mod_name = mod_name.replace('/', '.')
def f(m):
return '"""\n%s\n%s\n' % (mod_name, '~' * len(mod_name))
new_content = re.sub(r'^"""\n(kallithea\..*\n)(~+\n)?', f, org_content, count=1, flags=re.MULTILINE)
if new_content != org_content:
with open(fn, 'w') as f:
f.write(new_content)