On 08/11/2011 09:49 AM, Gelonida N wrote:

Thanks to Derek's answer pylint.lint.Run() doesn't exit anymore.

> from pylint import lint
> for filename in filenames:
>       args = [ '-f',  "text", pm_file)
>        lint.Run(args, exit=False) \
>

Now I still struggle capturing stdout / stderr of lint.Run()

My first naive approach was

from pylint import lint
from cStringIO import StringIO
from pylint import lint
for filename in filenames:
    args = [ '-f',  "text", pm_file)
    old_stdout = sys.stdout
    old_stderr = sys.stderr
    sys.stdout = my_stdout = StringIO()
    sys.stderr = my_stderr = StringIO()

    lint.Run(args, exit=False)

    sys.stdout = old_stdout
    sys.stderr = old_stderr

    output_str = my_stdout.getvalue() + my_stderr.getvalue()
    do_something_with(output_str)

However it fails.

I gather 0 characters in output_str and pylint.lin.Run still reports to
the console.

Have to check further.



_______________________________________________
Python-Projects mailing list
[email protected]
http://lists.logilab.org/mailman/listinfo/python-projects

Reply via email to