def download_image_files(self, image_id, destdir): """ Downloads the manifest.xml and all AMI parts for image_id to destdir """ if not os.path.isdir(destdir): raise exception.BaseException( "destination directory '%s' does not exist" % destdir) widgets = [ 'file: ', progressbar.Percentage(), ' ', progressbar.Bar(marker=progressbar.RotatingMarker()), ' ', progressbar.ETA(), ' ', progressbar.FileTransferSpeed() ] files = self.get_image_files(image_id) def _dl_progress_cb(trans, total): pbar.update(trans) log.info("Downloading image: %s" % image_id) for file in files: widgets[0] = "%s:" % file.name pbar = progressbar.ProgressBar(widgets=widgets, maxval=file.size).start() file.get_contents_to_filename(os.path.join(destdir, file.name), cb=_dl_progress_cb) pbar.finish()
def progress_bar(self): if not self._progress_bar: widgets = ['FileTransfer: ', ' ', progressbar.Percentage(), ' ', progressbar.Bar(marker=progressbar.RotatingMarker()), ' ', progressbar.ETA(), ' ', progressbar.FileTransferSpeed()] pbar = progressbar.ProgressBar(widgets=widgets, maxval=1, force_update=True) self._progress_bar = pbar return self._progress_bar