Open keyz182 opened 4 years ago
Hi @keyz182,
You have to look into how to do subprocesses with asyncio: https://docs.python.org/3/library/asyncio-subprocess.html#examples Then start a coroutine that consumes the output from the streamreader, and send it to a window.
It could also be worth looking at ptterm: https://github.com/prompt-toolkit/ptterm That's a user control that implements a virtual vt terminal and can run any subprocess in there. It's not well maintained unfortunately. Check out the prompt-toolkit-3.0 branch.
I've been poking around at this for a bit now, and I'm drawing a blank as to how I'd do this.
The basic use case is - I'd like to run the command
docker-compose up
, and stream it's output. If I run that command alone, it just prints it's output tostdout
, I'd like it to do that, but within a window/component. Later, I'd like to add a menu, and a second window to show some other bits, but right now, I'd be happy if I could just get the basic use case up and running.From
subprocess.Popen
I can either obtain a BufferedReader, or I believe the FD for it'sstdout
to treat it like a pipe/file.Any pointers?