Re: Popen and reading stdout in windows
Joseph L. Casale jcas...@activenetwerx.com writes: You leave out an awful amount of detail. I have no idea what ST is, so I'll have to guess your real problem. Ugh, sorry guys its been one of those days, the post was rather useless... I am using Popen to run the exe with communicate() and I have sent stdout to PIPE without luck. Just not sure what is the proper way to iterate over the stdout as it eventually makes its way from the buffer. You could try Sarge which is a wrapper for subprocess providing command pipeline functionality. http://sarge.readthedocs.org/ -- Pete Forman -- http://mail.python.org/mailman/listinfo/python-list
Re: Popen and reading stdout in windows
On Jun 11, 2013 12:21 AM, Pete Forman petef4+use...@gmail.com wrote: Joseph L. Casale jcas...@activenetwerx.com writes: You leave out an awful amount of detail. I have no idea what ST is, so I'll have to guess your real problem. Ugh, sorry guys its been one of those days, the post was rather useless... I am using Popen to run the exe with communicate() and I have sent stdout to PIPE without luck. Just not sure what is the proper way to iterate over the stdout as it eventually makes its way from the buffer. You could try Sarge which is a wrapper for subprocess providing command pipeline functionality. http://sarge.readthedocs.org/ Or Plumbum: http://plumbum.readthedocs.org Cheers, Chris -- http://mail.python.org/mailman/listinfo/python-list
RE: Popen and reading stdout in windows
On Tue, 11 Jun 2013 01:50:07 +, Joseph L. Casale wrote: I am using Popen to run the exe with communicate() and I have sent stdout to PIPE without luck. Just not sure what is the proper way to iterate over the stdout as it eventually makes its way from the buffer. The proper way is: p = subprocess.Popen(..., stdout=subprocess.PIPE) for line in p.stdout: # use 'line' p.wait() If the program uses stdin, matters get more complicated. -- http://mail.python.org/mailman/listinfo/python-list
Re: Popen and reading stdout in windows
On 2013-06-10, Joseph L. Casale jcas...@activenetwerx.com wrote: I have a use where writing an interim file is not convenient and I was hoping to iterate through maybe 100k lines of output by a process as its generated or roughly anyways. Seems to be a common question on ST, and more easily solved in Linux. Anyone currently doing this with Python 2.7 in windows and can share some guidance? http://docs.python.org/2/library/subprocess.html -- Grant Edwards grant.b.edwardsYow! All of life is a blur at of Republicans and meat! gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Popen and reading stdout in windows
On 06/10/2013 02:37 PM, Joseph L. Casale wrote: I have a use where writing an interim file is not convenient and I was hoping to iterate through maybe 100k lines of output by a process as its generated or roughly anyways. Seems to be a common question on ST, and more easily solved in Linux. Anyone currently doing this with Python 2.7 in windows and can share some guidance? You leave out an awful amount of detail. I have no idea what ST is, so I'll have to guess your real problem. You've got a process (myprog.exe) which generates a medium amount of output to stdout, and you want to process that data in a python program as it's being output, but without first writing it to a file. If by process you meant grep, the answer would be as simple as myprocess | grep parm1 parm2 But you want to write something (not called grep) in Python. myprocess | python myfilter.py The question is how to write myfilter.py Answer is to use stdin as you would a file. it's already open for you, and it'll get the data as it's being generated (plus or minus some buffering). So you can simply do something like: import sys for index, line in enumerate(sys.stdin): print index, line This trivial filter adds a line number in front of every line. But you could do anything there. And you might not need enumerate if you don't care about the line number. -- DaveA -- http://mail.python.org/mailman/listinfo/python-list
RE: Popen and reading stdout in windows
You leave out an awful amount of detail. I have no idea what ST is, so I'll have to guess your real problem. Ugh, sorry guys its been one of those days, the post was rather useless... I am using Popen to run the exe with communicate() and I have sent stdout to PIPE without luck. Just not sure what is the proper way to iterate over the stdout as it eventually makes its way from the buffer. Thanks! jlc -- http://mail.python.org/mailman/listinfo/python-list