3

I'm running the following command from within a PowerShell script. My problem is that the output from gitstats.py is buffered. This program can take a few minutes and I don't see any of my progress messages until the end.

git log -m -p --word-diff --date=iso | python d:\RepoStats\gitstats.py

within gitstats.py I'm printing using the following syntax:

sys.stdout.write("hi mom")
sys.stdout.buffer.flush()

Any way to get the stdout from python to show realtime in Powershell?

sisdog
  • 2,649
  • 2
  • 29
  • 49
  • `cmd /c git .... "|" python ...` – wOxxOm Feb 26 '17 at 04:59
  • @wOxxOm: Assuming this fixes the problem: can you explain why and how `cmd` handles buffering differently from PowerShell in this case? – mklement0 Feb 26 '17 at 13:50
  • Yeah, it fixes the problem. I've been thinking about implementing a PS wrapper that's why haven't yet posted an answer. – wOxxOm Feb 26 '17 at 19:23
  • @wOxxOm - thx, this worked but I didn't notice it at first because I was running my *.ps1 file in the PowerShell ISE which still buffered things - the command line worked. Look forward to your official answer so I can pad your stats. – sisdog Feb 28 '17 at 04:36

0 Answers0