Success with subprocess communicate on Windows?
Terry Reedy
tjreedy at udel.edu
Tue Jul 1 17:05:58 EDT 2014
I am mentoring a GSOC student, Saimadhav Heblikar, who is working on
adding the following feature to Idle: submit the editor text to an
external program, such as pyflakes, and display the result in an
OutputWindow. If it reports line numbers with problems, as pyflakes
does, users will be able to jump to the line in the file (this exists
already for multiple-file grep output).
The 'obvious' implementation is to use subprocess.Open.communicate to
run the process and capture the output. The prototype code at
http://bugs.python.org/issue21880 works on linux. The key part of the
new code at http://bugs.python.org/file35819/3rdpartychecker-v2.diff is
+from subprocess import Popen, PIPE
...
+ proc = Popen(args, stdout=PIPE, stderr=PIPE)
+ proc.wait()
+ output, error = map(lambda b:b.decode('utf-8'),
proc.communicate())
It does not work on Windows. As I reported on
http://bugs.python.org/issue8631, msg222053,
>>> subprocess.check_output("pyflakes -h")
works in the interpreter and Idle shell, while
>>> s.check_output("pyflakes c:\programs\python34\lib\turtle.py")
gives bizarre output in the interpreter and hangs in the idle shell, as
does the code above.
My question is whether anyone reading that has had success getting
subprocess output capture to work consistently on Windows?
--
Terry Jan Reedy
More information about the Python-list
mailing list