[python-win32] win32pipe.popen and stdout

Leeuw van der, Tim tim.leeuwvander at nl.unisys.com
Mon May 9 11:47:39 CEST 2005


Just continue reading until end-of-file, just like you'd read any other file! (for instance when reading a file line-by-line). The PDF is still being produced as you read it, so just read on until end of file and append it to your buffer. (Perhaps you can read it line-by-line, isn't PDF as sort of text format?)

cheers,

--Tim

-----Original Message-----
From: python-win32-bounces at python.org [mailto:python-win32-bounces at python.org]On Behalf Of Jurgen Kareta
Sent: Monday, May 09, 2005 11:27 AM
To: python-win32 Mailinglist
Subject: [python-win32] win32pipe.popen and stdout


Hi,

I have two questions about win32pipe popen methods and stdin and stdout:

I played with the ps2pdf batch in ghostscript. If I call the batch from 
python with win32pipe.popen, giving two real files as soure and 
destination, it works fine.  Calling the batch with a '-' for 
destination, the output is send to stdout. But if I try to fetch it 
inside python I get only roundabout 300 bytes and the rest is lost (with 
the read method). If I add another read statement I get a few other 
bytes from the stdout.

code:
pipe = win32pipe.popen('..\\ps2pdf.bat test.ps -','r')
msvcrt.setmode(pipe.fileno(),O_BINARY)
pdf_file=pipe.read()
pipe.close()

/code

Is there a way the fetch the hole content of stdout ?

second question:
I'm wondering how to set the stdin for the subprocess:
(input,output) = win32pipe.popen2('my_command input.write(my_content))

would the above statement set the stdin pipe of my_command with my_content ?

thanks in advance
Jürgen



_______________________________________________
Python-win32 mailing list
Python-win32 at python.org
http://mail.python.org/mailman/listinfo/python-win32


More information about the Python-win32 mailing list