From 147cab8ac14c76ba837e06ca0d923472d4f4a2db Mon Sep 17 00:00:00 2001 From: Sebastien Luttringer <sebastien.luttringer@smartjog.com> Date: Thu, 13 Oct 2011 16:42:33 +0200 Subject: [PATCH] Display progress bar during image creatio --- installsystems/image.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/installsystems/image.py b/installsystems/image.py index 2f6e353..fbef631 100644 --- a/installsystems/image.py +++ b/installsystems/image.py @@ -229,11 +229,13 @@ class SourceImage(Image): # compute dname to set as a base directory dname = os.path.basename(data_path) try: + dfo = PipeFile(tar_path, "w", progressbar=True) # Tarballing - tarball = Tarball.open(tar_path, "w:gz", dereference=False) + tarball = Tarball.open(fileobj=dfo, mode="w|gz", dereference=False) tarball.add(data_path, arcname="/", recursive=True, filter=self._create_payload_tarball_filter) tarball.close() + dfo.close() except Exception as e: raise Exception("Unable to create payload tarball %s: %s" % (tar_path, e)) @@ -251,14 +253,14 @@ class SourceImage(Image): Create a payload file Only gzipping it ''' - fsource = PipeFile(source, "r") + fsource = PipeFile(source, "r", progressbar=True) # open file not done in GzipFile, to escape writing of filename # in gzip file. This change md5. fdest = open(dest, "wb") fdest = gzip.GzipFile(filename=os.path.basename(source), fileobj=fdest, mtime=os.stat(source).st_mtime) - shutil.copyfileobj(fsource, fdest) + fsource.consume(fdest) fsource.close() fdest.close() -- GitLab