tomerfiliba / plumbum

Plumbum: Shell Combinators
https://plumbum.readthedocs.io
MIT License
2.8k stars 182 forks source link

Query: How to achieve more realtime output #565

Open JohnDuncanScott opened 2 years ago

JohnDuncanScott commented 2 years ago

I had a look through the docs and issues but wasn't able to find something specific to this, so apologies if I missed it. If I run a command that outputs a lot of information (like choco install nodejs for example, which installs Node via Chocolatey and has lots of progress output), the output is only shown in 1 flush after the command has been finished. Is there any way of getting Plumbum to output to the console more regularly so you can see the progress of longer running and verbose commands?

andry81 commented 2 years ago

You can take a look at the implementation around git/svn executables from here:

https://github.com/andry81/tacklelib/blob/trunk/python/cmdoplib/cmdoplib.callgit.xsh https://github.com/andry81/tacklelib/blob/trunk/python/cmdoplib/cmdoplib.callsvn.xsh https://github.com/andry81/tacklelib/blob/trunk/python/cmdoplib/cmdoplib.std.xsh https://github.com/andry81/tacklelib/blob/trunk/python/cmdoplib/cmdoplib.gitsvn.xsh

Search for: call_git(, call_svn(, call(

There is no_except option which switches to more realtime mode.

JohnDuncanScott commented 2 years ago

Thanks very much :). So looking through that code it seems to bit that triggers realtime are the sys parts: local["choco"]["install", "nodejs", "-y"].run(stdout = sys.stdout, stderr = sys.stderr) which seems equivalent to: local["choco"]["install", "nodejs", "-y"](stdout = sys.stdout, stderr = sys.stderr)

I thought this would essentially be the default, hence the confusion. It would be great if this was included in the documentation somewhere. Also not sure if it's possible to set this as the default somehow to avoid duplicated this everywhere?