ProgressBarOrSpinner

class astropy.utils.console.ProgressBarOrSpinner(total, msg, color='default', file=<open file '<stdout>', mode 'w' at 0x7f42ba5531e0>) [edit on github][source]

A class that displays either a ProgressBar or Spinner depending on whether the total size of the operation is known or not.

It is designed to be used with the with statement:

if file.has_length():
    length = file.get_length()
else:
    length = None
bytes_read = 0
with ProgressBarOrSpinner(length) as bar:
    while file.read(blocksize):
        bytes_read += blocksize
        bar.update(bytes_read)

Methods Summary

update(value) Update the progress bar to the given value (out of the total given to the constructor.

Methods Documentation

update(value) [edit on github][source]

Update the progress bar to the given value (out of the total given to the constructor.

Page Contents