ProgressBarOrSpinner#

class astropy.utils.console.ProgressBarOrSpinner(total, msg, color='default', file=None)[source]#

Bases: object

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)
Parameters:
totalint or None

If an int, the number of increments in the process being tracked and a ProgressBar is displayed. If None, a Spinner is displayed.

msgstr

The message to display above the ProgressBar or alongside the Spinner.

colorstr, optional

The color of msg, if any. Must be an ANSI terminal color name. Must be one of: black, red, green, brown, blue, magenta, cyan, lightgrey, default, darkgrey, lightred, lightgreen, yellow, lightblue, lightmagenta, lightcyan, white.

filefile-like (writeable), optional

The file to write the to. Defaults to sys.stdout. If file is not a tty (as determined by calling its isatty member, if any), only msg will be displayed: the ProgressBar or Spinner will be silent.

Methods Summary

update(value)

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

Methods Documentation

update(value)[source]#

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