# 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
with ProgressBarOrSpinner(length) as bar:

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.

filewritable file-like object, 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(self, value) Update the progress bar to the given value (out of the total given to the constructor.

Methods Documentation

update(self, value)[source]

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