Progress should override output

Bug #1537799 reported by Wernight
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Duplicity
New
Undecided
Unassigned

Bug Description

Currently outputs with --progress look like:
2.6GB 00:29:40 [1.6MB/s] [==========> ] 26% ETA 1h 21min
2.6GB 00:29:43 [1.6MB/s] [==========> ] 26% ETA 1h 21min
2.6GB 00:29:46 [1.4MB/s] [==========> ] 26% ETA 1h 21min
2.6GB 00:29:49 [1.5MB/s] [==========> ] 26% ETA 1h 21min
2.7GB 00:29:52 [1.5MB/s] [==========> ] 26% ETA 1h 21min
2.7GB 00:29:55 [1.6MB/s] [==========> ] 26% ETA 1h 21min
2.7GB 00:29:58 [1.6MB/s] [==========> ] 26% ETA 1h 21min
2.7GB 00:30:01 [1.4MB/s] [==========> ] 26% ETA 1h 21min
2.7GB 00:30:04 [1.5MB/s] [==========> ] 27% ETA 1h 21min
2.7GB 00:30:07 [1.5MB/s] [==========> ] 27% ETA 1h 21min
2.7GB 00:30:10 [1.6MB/s] [==========> ] 27% ETA 1h 21min
2.7GB 00:30:13 [1.6MB/s] [==========> ] 27% ETA 1h 20min
2.7GB 00:30:17 [1.6MB/s] [==========> ] 27% ETA 1h 20min
2.7GB 00:30:20 [1.4MB/s] [==========> ] 27% ETA 1h 20min
2.7GB 00:30:23 [1.5MB/s] [==========> ] 27% ETA 1h 20min
2.7GB 00:30:26 [1.6MB/s] [==========> ] 27% ETA 1h 20min
2.7GB 00:30:29 [1.6MB/s] [==========> ] 27% ETA 1h 20min
2.7GB 00:30:32 [1.7MB/s] [==========> ] 27% ETA 1h 20min
2.7GB 00:30:35 [1.4MB/s] [==========> ] 27% ETA 1h 20min
2.7GB 00:30:38 [1.4MB/s] [===========> ] 27% ETA 1h 20min
2.7GB 00:30:41 [1.5MB/s] [===========> ] 27% ETA 1h 20min

It could easily just update that line. There are two simple ways to do that (in Python):

import sys
from time import sleep

# '\r': Simpler way, having issue when console width is too small and output gets wrapped.
for i in range(0, 101, 5):
    sys.stdout.write("Download progress: {}% \r".format(i))
    sys.stdout.flush()

    # Do work here...
    sleep(0.1)
sys.stdout.write('\n')

# '\b': Better way
sys.stdout.write("Download progress: ")
for i in range(0, 101, 5):
    s = '%d%%' % i
    sys.stdout.write(s)

    # Do work here...
    sleep(0.1)

    sys.stdout.write('\b' * len(s))
sys.stdout.write('\n')

Revision history for this message
Ratan (ratan-r-sur) wrote :

+1

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.