##// 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:

r8156:abb83e4e default
r8795:fe050a93 stable
Show More
pyflakes
39 lines | 1.2 KiB | text/plain | TextLexer
#!/usr/bin/env python3
"""
pyflakes with filter configuration for Kallithea.
Inspired by pyflakes/api.py and flake8/plugins/pyflakes.py .
"""
import sys
import pyflakes.api
import pyflakes.messages
class Reporter:
warned = False
def flake(self, warning):
# ignore known warnings
if isinstance(warning, pyflakes.messages.UnusedVariable):
return
if warning.filename == 'kallithea/bin/kallithea_cli_ishell.py':
if isinstance(warning, pyflakes.messages.ImportStarUsed) and warning.message_args == ('kallithea.model.db',):
return
if isinstance(warning, pyflakes.messages.UnusedImport) and warning.message_args == ('kallithea.model.db.*',):
return
print('%s:%s %s [%s %s]' % (warning.filename, warning.lineno, warning.message % warning.message_args, type(warning).__name__, warning.message_args))
self.warned = True
def unexpectedError(self, filename, msg):
print('Unexpected error for %s: %s' % (filename, msg))
reporter = Reporter()
for filename in sorted(set(sys.argv[1:])):
pyflakes.api.checkPath(filename, reporter=reporter)
if reporter.warned:
raise SystemExit(1)