I am a noob when it comes to python. I have a python script which gives me output like this:
[last] ZVZX-W3vo9I: Downloading video webpage
[last] ZVZX-W3vo9I: Extracting video information
[download] Destination: myvideo.flv
[download] 9.9% of 10.09M at 3.30M/s ETA 00:02
The last line keeps getting updated with new values of progress. I want to change this. Instead of updating I want a new line to be printed each time. How can i do this? I think the part concerned is this bit:
def report_progress(self, percent_str, data_len_str, speed_str, eta_str):
"""Report download progress."""
self.to_stdout(u'\r[download] %s of %s at %s ETA %s' %
(percent_str, data_len_str, speed_str, eta_str), skip_eol=True)
If more code needs to be seen please let me know so that I can show you what is needed to solve this.
Thank you very much for any help.
I'm thinking you may just need to change:
to:
and get rid of the "
\r
" to see what happens. I think you'll be pleasantly surprised :-)You can take out the \r, which moves to the cursor back to the beginning of the line and take out the skip_eol=True probably. Perhaps:
If I understand your request properly, you should be able to change that function to this:
That will print the output on a new line each time.
The "update" effect is achieved by '\r'.
Try this in a Python (2.x) shell:
\r just returns the cursor to the beginning of the line.