python-shell
python-shell copied to clipboard
[New Feature] Gracefully handle carriage returns
Many programs utilize carriage return in the output updates to the console without pushing a new line. It would be sweet if python-shell could handle these gracefully and fire a new event like 'crdata' so the consumer can gracefully handle these line updates.
stream-splitter seems like a good module that can help to accomplish this: https://github.com/samcday/node-stream-splitter
Thanks for this cool tool!
A transform stream sure is nice but I think it would be unnecessarily complex. We could easily make the message splitting more flexible by allowing to set the ending characters in the options. See: https://github.com/extrabacon/python-shell/blob/master/index.js#L200
I tried that last night but it does not give sense of progress when watching the output which is my goal; as the Python script sends \r chars, I want that line immediately so I can update my UI and pass the progress update.
Therefore I think it needs to be done further up the stdout processing chain.
On December 17, 2015 9:22:00 AM EST, Nicolas Mercier [email protected] wrote:
A transform stream sure is nice but I think it would be unnecessarily complex. We could easily make the message splitting more flexible by allowing to set the ending characters in the options. See: https://github.com/extrabacon/python-shell/blob/master/index.js#L200
Reply to this email directly or view it on GitHub: https://github.com/extrabacon/python-shell/issues/23#issuecomment-165463943
Sent from my Android device with K-9 Mail. Please excuse my brevity.
Sounds like a buffering issue. Stdin and stdout are buffered by default and you need to flush in order to "update immediately".
I agree. It should be possible to accomplish this and it would be a pretty cool feature IMO.
Thanks for putting some thought into it.