# interpreted as representing official policies, either expressed
# or implied, of GRNET S.A.
-from image_creator.util import get_command, warn, progress_generator, success
+from image_creator.util import get_command
+from image_creator.util import warn, progress, success, output
from image_creator import FatalError
-from clint.textui import puts
import stat
import os
the Disk instance.
"""
- puts("Examining source media `%s'..." % self.source, False)
+ output("Examining source media `%s'..." % self.source, False)
sourcedev = self.source
mode = os.stat(self.source).st_mode
if stat.S_ISDIR(mode):
success('looks like a block device')
# Take a snapshot and return it to the user
- puts("Snapshotting media source...", False)
+ output("Snapshotting media source...", False)
size = blockdev('--getsize', sourcedev)
cowfd, cow = tempfile.mkstemp()
os.close(cowfd)
def enable(self):
"""Enable a newly created DiskDevice"""
- self.progressbar = progress_generator("Launching helper VM: ")
+ self.progressbar = progress("Launching helper VM: ")
self.progressbar.next()
eh = self.g.set_event_callback(self.progress_callback,
guestfs.EVENT_PROGRESS)
self.progressbar.send(100)
self.progressbar = None
- puts('Inspecting Operating System...', False)
+ output('Inspecting Operating System...', False)
roots = self.g.inspect_os()
if len(roots) == 0:
raise FatalError("No operating system found")
def mount(self):
"""Mount all disk partitions in a correct order."""
+
+ output("Mounting image...", False)
mps = self.g.inspect_get_mountpoints(self.root)
# Sort the keys to mount the fs in a correct order.
try:
self.g.mount(dev, mp)
except RuntimeError as msg:
- print "%s (ignored)" % msg
+ warn("%s (ignored)" % msg)
+ success("done")
def umount(self):
"""Umount all mounted filesystems."""
disk and then updating the partition table. The new disk size
(in bytes) is returned.
"""
- puts("Shrinking image (this may take a while)...", False)
- sys.stdout.flush()
+ output("Shrinking image (this may take a while)...", False)
dev = self.g.part_to_dev(self.root)
parttype = self.g.part_get_parttype(dev)
blocksize = 2 ** 22 # 4MB
size = self.size()
progress_size = (size + 2 ** 20 - 1) // 2 ** 20 # in MB
- progressbar = progress_generator("Dumping image file: ", progress_size)
+ progressbar = progress("Dumping image file: ", progress_size)
source = open(self.device, "r")
try: