FAQ
Here's a small Python program I use to grab the output from rake:

=====

from subprocess import Popen, PIPE

p = Popen(args='c:\\ruby\\bin\\ruby.exe c:\\ruby\\bin\\rake -T',
cwd=u'c:\\Users\\ericp\\testing\\file07',
shell=True,
stdin=None,
stderr=PIPE,
stdout=PIPE,
creationflags=0x8000000
);
p.wait()
data = p.stdout.read()
print data

=====

This is on Windows Vista. With Rails 1.2.6 there was no problem.
After
upgrading to Rails 2.0.1, the program now hangs at the call to the
wait()
command. If I manually kill the ruby.exe process, I get some of the
expected
output, but not all of it.

I can run the above command from the command-line with no problem.

The rake code that Ruby loads did change moving from 1.2.6 to 2.0.1,
but
subprocess should run the command to completion.

I'm not sure what happens yet on XP, or other platforms. I'd like to
get this
working on Vista, though. Any ideas.

Thanks,
Eric

Search Discussions

  • Christian Heimes at Dec 13, 2007 at 2:01 am

    Eric Promislow wrote:
    Here's a small Python program I use to grab the output from rake:

    =====

    from subprocess import Popen, PIPE

    p = Popen(args='c:\\ruby\\bin\\ruby.exe c:\\ruby\\bin\\rake -T',
    cwd=u'c:\\Users\\ericp\\testing\\file07',
    shell=True,
    stdin=None,
    stderr=PIPE,
    stdout=PIPE,
    creationflags=0x8000000
    );
    p.wait()
    data = p.stdout.read()
    print data
    Your usage of wait() is dangerous. The code can block indefinitely when
    the stdout or stderr buffer is full.

    Christian
  • Eric Promislow at Dec 13, 2007 at 2:14 am

    Your usage of wait() is dangerous. The code can block indefinitely when
    the stdout or stderr buffer is full.

    Christian
    That's what it is. `rake -T` returns more data in Rails 2.0.1
    than it did in 1.2.6 -- cross-language breakage logically explained.
    Thank you, Christian.

    - Eric
  • Christian Heimes at Dec 13, 2007 at 2:26 am

    Eric Promislow wrote:
    Your usage of wait() is dangerous. The code can block indefinitely when
    the stdout or stderr buffer is full.

    Christian
    That's what it is. `rake -T` returns more data in Rails 2.0.1
    than it did in 1.2.6 -- cross-language breakage logically explained.
    Thank you, Christian.
    You can use stdout, stderr = p.communicate() but keep in mind that the
    data is buffered in memory. I suggest a temporary file if you expect
    more than a couple of MB.

    Christian

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppython-list @
categoriespython
postedDec 13, '07 at 1:34a
activeDec 13, '07 at 2:26a
posts4
users2
websitepython.org

People

Translate

site design / logo © 2023 Grokbase