astro py:docs

- Index
- Modules

### Navigation

- next »
- « previous |
- Astropy v0.3 »
- Astropy Core Package Utilities (`astropy.utils`) »
- ProgressBarOrSpinner

# ProgressBarOrSpinner

class `astropy.utils.console.``ProgressBarOrSpinner`(total, msg, color=u'default', file=None)

  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)

  Methods Summary

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

  Methods Documentation

  `update`(value)

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