Is there a way to use the program pv from within python so as to get the progress of an operation?
So far I have the following:
p0 = sp.Popen(["pv", "-f", args.filepath],
bufsize=0,
stdout=sp.PIPE,
stderr=sp.PIPE)
p1 = sp.Popen(["awk", "{print $1, $2, $1, $3, $4 }", "{}".format(args.filepath)],
stdout=sp.PIPE,
stdin=p0.stdout)
But I'm having trouble getting continuous output from p0
. I tried:
for line in p0.stderr:
print("line:", line)
But this waits for the process to finish and then only prints the last progress report from pv
. Does anybody know how I can get it to print the continuously updating status?