python-progressbar icon indicating copy to clipboard operation
python-progressbar copied to clipboard

Prefix is not working

Open SpeedyIndeedy opened this issue 3 years ago • 3 comments

Hi, the download speed as well as file size value is shown correct but there is no prefix. Speed: 3.3 B/s Size: 121.0 B instead of Speed: 3.3 MiB/s Size: 121.0 MiB

I tried FileTransferSpeed() and AdaptiveTransferSpeed() both, but same issue.

Versions

  • Python version: 3.10
  • Python distribution/environment: CPython
  • Operating System: Windows 10
  • Package version: 3.55.0

SpeedyIndeedy avatar Dec 26 '21 12:12 SpeedyIndeedy

What are you passing along as a value? If you're setting it to 3.3 it will be 3.3 bytes. For 3.3 MiB you need 3.3*1024*1024 = 3460300 instead.

wolph avatar Dec 27 '21 02:12 wolph

I just kept it empty 🙄

SpeedyIndeedy avatar Dec 28 '21 11:12 SpeedyIndeedy

In that case I am guessing that you are updating the progress bar every megabyte instead of every byte. Hard to say without the code though ;)

Since an extreme amount of updates is generally not ideal for performance either, I would recommend explicitly updating with the amount of bytes you've downloaded. This should do the trick: bar.update(bytes)

wolph avatar Dec 28 '21 12:12 wolph