return True
def cleanup_mounts(chrootdir):
- dev_null = os.open("/dev/null", os.O_WRONLY)
umountcmd = misc.find_binary_path("umount")
for point in BIND_MOUNTS:
args = [ umountcmd, "-l", chrootdir + point ]
- subprocess.call(args, stdout=dev_null, stderr=dev_null)
+ msger.run(args, True)
abs_chrootdir = os.path.abspath(chrootdir)
with open('/proc/mounts') as f:
continue
args = [ umountcmd, "-l", point ]
- ret = subprocess.call(args, stdout=dev_null, stderr=dev_null)
+ ret = msger.run(args, True)
if ret != 0:
msger.warning("failed to unmount %s" % point)
- os.close(dev_null)
return ret
- os.close(dev_null)
return 0
def setup_chrootenv(chrootdir, bindmounts = None):
if not ksconf:
return
- try:
- ks = kickstart.read_kickstart(ksconf)
- ksrepos = misc.get_repostrs_from_ks(ks)
- msger.info("Retrieving repo metadata:")
- repometadata = misc.get_metadata_from_repos(ksrepos, self.create['cachedir'])
- msger.raw(" DONE")
-
- self.create['ks'] = ks
- self.create['repomd'] = repometadata
- self.create['name'] = os.path.splitext(os.path.basename(ksconf))[0]
- except Exception, e:
- raise errors.KsError("Unable to load kickstart file '%s': %s" % (ksconf, e))
+ ks = kickstart.read_kickstart(ksconf)
+ ksrepos = misc.get_repostrs_from_ks(ks)
+
+ msger.info("Retrieving repo metadata:")
+ repometadata = misc.get_metadata_from_repos(ksrepos, self.create['cachedir'])
+ msger.raw(" DONE")
+
+ self.create['ks'] = ks
+ self.create['repomd'] = repometadata
+ self.create['name'] = os.path.splitext(os.path.basename(ksconf))[0]
def setProperty(self, key, value):
if not hasattr(self, key):
pass
def __run_post_scripts(self):
- msger.info("Running scripts")
+ msger.info("Running scripts ...")
for s in kickstart.get_post_scripts(self.ks):
(fd, path) = tempfile.mkstemp(prefix = "ks-script-",
dir = self._instroot + "/tmp")
if self.__img_compression_method == "bz2":
bzip2 = find_binary_path('bzip2')
msger.info("Compressing %s with bzip2. Please wait..." % img_location)
- rc = subprocess.call([bzip2, "-f", img_location])
+ rc = msger.run([bzip2, "-f", img_location])
if rc:
raise CreatorError("Failed to compress image %s with %s." % (img_location, self.__img_compression_method))
for bootimg in glob.glob(os.path.dirname(img_location) + "/*-boot.bin"):
msger.info("Compressing %s with bzip2. Please wait..." % bootimg)
- rc = subprocess.call([bzip2, "-f", bootimg])
+ rc = msger.run([bzip2, "-f", bootimg])
if rc:
raise CreatorError("Failed to compress image %s with %s." % (bootimg, self.__img_compression_method))
makedirs(destdir)
# Ensure all data is flushed to _outdir
- synccmd = find_binary_path("sync")
- subprocess.call([synccmd])
+ msger.run('sync', True)
for f in os.listdir(self._outdir):
shutil.move(os.path.join(self._outdir, f),
#
import os, sys
-import subprocess
from baseimager import BaseImageCreator
from mic import msger
msger.info("Copying %s to %s ..." % (self._instroot, destdir + "/" + self.name))
args = ['cp', "-af", self._instroot, destdir + "/" + self.name ]
- subprocess.call(args)
+ msger.run(args)
ignores = ["/dev/fd", "/dev/stdin", "/dev/stdout", "/dev/stderr", "/etc/mtab"]
for exclude in ignores:
import os, sys
import glob
import shutil
-import subprocess
from mic import kickstart, msger
from mic.utils import fs_related, rpmmisc
args.append(isodir)
- if subprocess.call(args) != 0:
+ if msger.run(args) != 0:
raise CreatorError("ISO creation failed!")
""" It should be ok still even if you haven't isohybrid """
if isohybrid:
args = [isohybrid, "-partok", iso ]
- if subprocess.call(args) != 0:
+ if msger.run(args) != 0:
raise CreatorError("Hybrid ISO creation failed!")
self.__implant_md5sum(iso)
implantisomd5 = ""
return
- subprocess.call([implantisomd5, iso], stdout=sys.stdout, stderr=sys.stderr)
+ msger.run([implantisomd5, iso])
def _stage_final_image(self):
try:
import os
import shutil
-import subprocess
import re
from mic import msger
overlaysuffix = "-%s-%s" % (diskmount.fslabel, diskmount.uuid)
args = ['cp', "-Rf", isodir + "/isolinux", usbmnt + "/syslinux"]
- rc = subprocess.call(args)
+ rc = msger.run(args)
if rc:
raise CreatorError("Can't copy isolinux directory %s" % (isodir + "/isolinux/*"))
path = os.path.join(syslinux_path, f)
if os.path.isfile(path):
args = ['cp', path, usbmnt + "/syslinux/"]
- rc = subprocess.call(args)
+ rc = msger.run(args)
if rc:
raise CreatorError("Can't copy syslinux file %s" % (path))
else:
args = ['dd', "if=/dev/zero", "of=" + usbmnt + "/LiveOS/" + overfile, "count=%d" % overlaysizemb, "bs=1M"]
else:
args = ['dd', "if=/dev/null", "of=" + usbmnt + "/LiveOS/" + overfile, "count=1", "bs=1M", "seek=%d" % overlaysizemb]
- rc = subprocess.call(args)
+ rc = msger.run(args)
if rc:
raise CreatorError("Can't create overlay file")
text = text.replace("liveimg", "liveimg overlay=" + usblabel)
msger.info("Initializing swap file")
swapfile = usbmnt + "/LiveOS/" + "swap.img"
args = ['dd', "if=/dev/zero", "of=" + swapfile, "count=%d" % swapsizemb, "bs=1M"]
- rc = subprocess.call(args)
+ rc = msger.run(args)
if rc:
raise CreatorError("Can't create swap file")
args = ["mkswap", "-f", swapfile]
- rc = subprocess.call(args)
+ rc = msger.run(args)
if rc:
raise CreatorError("Can't mkswap on swap file")
args = ['dd', "if=/dev/zero", "of=" + homefile, "count=%d" % homesizemb, "bs=1M"]
else:
args = ['dd', "if=/dev/null", "of=" + homefile, "count=1", "bs=1M", "seek=%d" % homesizemb]
- rc = subprocess.call(args)
+ rc = msger.run(args)
if rc:
raise CreatorError("Can't create home file")
args = [mkfscmd, "-F", "-j", homefile]
else:
args = [mkfscmd, homefile]
- rc = subprocess.call(args, stdout=sys.stdout, stderr=sys.stderr)
+ rc = msger.run(args)
if rc:
raise CreatorError("Can't mke2fs home file")
if fstype == "ext2" or fstype == "ext3":
tune2fs = fs_related.find_binary_path("tune2fs")
args = [tune2fs, "-c0", "-i0", "-ouser_xattr,acl", homefile]
- rc = subprocess.call(args, stdout=sys.stdout, stderr=sys.stderr)
+ rc = msger.run(args)
if rc:
raise CreatorError("Can't tune2fs home file")
fd = open(syslinuxcfg, "w")
fd.write(text)
fd.close()
- rc = subprocess.call(args)
+ rc = msger.run(args)
if rc:
raise CreatorError("Can't install boot loader.")
outimg = "%s/%s.usbimg" % (self._outdir, self.name)
args = ['dd', "if=" + mbrfile, "of=" + outimg, "seek=0", "conv=notrunc", "bs=1", "count=%d" % (mbrsize)]
- rc = subprocess.call(args)
+ rc = msger.run(args)
if rc:
raise CreatorError("Can't set MBR.")
import os
import stat
import shutil
-import subprocess
import urlgrabber.progress as progress
self._dep_checks.extend(["sync", "kpartx", "parted", "extlinux"])
def configure(self, repodata = None):
+ import subprocess
def chroot():
-
os.chroot(self._instroot)
os.chdir("/")
if os.path.exists(self._instroot + "/usr/bin/Xorg"):
subprocess.call(["/bin/chmod", "u+s", "/usr/bin/Xorg"], preexec_fn = chroot)
+
BaseImageCreator.configure(self, repodata)
def _get_fstab(self):
#Set MBR
mbrsize = os.stat("%s/usr/share/syslinux/mbr.bin" % self._instroot)[stat.ST_SIZE]
- ddcmd = fs_related.find_binary_path("dd")
- rc = subprocess.call([ddcmd, "if=%s/usr/share/syslinux/mbr.bin" % self._instroot, "of=" + loopdev])
+ rc = msger.run(['dd', "if=%s/usr/share/syslinux/mbr.bin" % self._instroot, "of=" + loopdev])
if rc != 0:
raise MountError("Unable to set MBR to %s" % loopdev)
#Set Bootable flag
parted = fs_related.find_binary_path("parted")
- dev_null = os.open("/dev/null", os.O_WRONLY)
- rc = subprocess.call([parted, "-s", loopdev, "set", "%d" % (bootdevnum + 1), "boot", "on"],
- stdout = dev_null, stderr = dev_null)
- os.close(dev_null)
+ rc = msger.run([parted, "-s", loopdev, "set", "%d" % (bootdevnum + 1), "boot", "on"], True)
#XXX disabled return code check because parted always fails to
#reload part table with loop devices. Annoying because we can't
#distinguish this failure from real partition failures :-(
#Ensure all data is flushed to disk before doing syslinux install
- subprocess.call(["sync"])
+ msger.run('sync', True)
fullpathsyslinux = fs_related.find_binary_path("extlinux")
- rc = subprocess.call([fullpathsyslinux, "-i", "%s/boot/extlinux" % self._instroot])
+ rc = msger.run([fullpathsyslinux, "-i", "%s/boot/extlinux" % self._instroot])
if rc != 0:
raise MountError("Unable to install syslinux bootloader to %sp%d" % (loopdev, (bootdevnum + 1)))
# kickstart.py : Apply kickstart configuration to a system
#
# Copyright 2007, Red Hat Inc.
+# Copyright 2009, 2010, 2011 Intel, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
fd.write("\n")
def __create_repo_file(self, repo, repodir):
- if not os.path.exists(self.path(repodir)):
- fs.makedirs(self.path(repodir))
+ fs.makedirs(self.path(repodir))
f = open(self.path(repodir + "/" + repo.name + ".repo"), "w")
self.__create_repo_section(repo, "base", f)
if repo.debuginfo:
self.__create_repo_file(repo, "/etc/zypp/repos.d")
""" Import repo gpg keys """
if repodata:
- dev_null = os.open("/dev/null", os.O_WRONLY)
for repo in repodata:
if repo['repokey']:
- subprocess.call([fs.find_binary_path("rpm"), "--root=%s" % self.instroot, "--import", repo['repokey']],
- stdout = dev_null, stderr = dev_null)
- os.close(dev_null)
+ msger.run(['rpm', "--root=%s" % self.instroot, "--import", repo['repokey']], True)
class RPMMacroConfig(KickstartConfig):
"""A class to apply the specified rpm macros to the filesystem"""
import os,sys
import re
-__ALL__ = ['set_mode', 'get_loglevel', 'set_loglevel', 'raw' 'debug', 'verbose', 'info', 'warning', 'error', 'ask', 'pause']
+__ALL__ = ['set_mode', 'get_loglevel', 'set_loglevel', 'raw' 'debug', 'verbose', 'info', 'warning', 'error', 'ask', 'pause', 'run']
# COLORs in ANSI
INFO_COLOR = 32 # green
if not msg:
msg = 'press <ENTER> to continue ...'
raw_input(msg)
+
+def run(cmdln_or_args, q=False):
+ """ q: quiet? """
+
+ from subprocess import *
+ if isinstance(cmdln_or_args, list):
+ cmdln = ' '.join(cmdln_or_args)
+ else:
+ cmdln = cmdln_or_args
+
+ p = Popen(cmdln, stdout=PIPE, stderr=PIPE, shell=True)
+ out = p.communicate()[0].strip()
+ if out and not q:
+ msg = 'running command: "%s"\n' % cmdln
+ msg += ' +----------------\n'
+ for line in out.splitlines():
+ msg += ' | %s\n' % line
+ msg += ' +----------------'
+ verbose(msg)
+
+ return p.returncode
if not sys.stdout.isatty():
args.append("-no-progress")
- ret = subprocess.call(args, stdout=sys.stdout, stderr=sys.stderr)
+ ret = msger.run(args)
if ret != 0:
raise SquashfsError("'%s' exited with error (%d)" %
(string.join(args, " "), ret))
def resize2fs(fs, size):
- dev_null = os.open("/dev/null", os.O_WRONLY)
- try:
- resize2fs = find_binary_path("resize2fs")
- return subprocess.call([resize2fs, fs, "%sK" % (size / 1024,)],
- stdout = dev_null, stderr = dev_null)
- finally:
- os.close(dev_null)
+ resize2fs = find_binary_path("resize2fs")
+ return msger.run([resize2fs, fs, "%sK" % (size / 1024,)], True)
def my_fuser(file):
ret = False
fuser = find_binary_path("fuser")
if not os.path.exists(file):
return ret
+
dev_null = os.open("/dev/null", os.O_WRONLY)
- rc = subprocess.call([fuser, "-s", file], stderr=dev_null)
+ rc = msger.run([fuser, "-s", file], True)
if rc == 0:
fuser_proc = subprocess.Popen([fuser, file], stdout=subprocess.PIPE, stderr=dev_null)
pids = fuser_proc.communicate()[0].strip().split()
return
makedirs(self.dest)
- rc = subprocess.call([self.mountcmd, "--bind", self.src, self.dest])
+ rc = msger.run([self.mountcmd, "--bind", self.src, self.dest])
if rc != 0:
raise MountError("Bind-mounting '%s' to '%s' failed" %
(self.src, self.dest))
if self.option:
- rc = subprocess.call([self.mountcmd, "--bind", "-o", "remount,%s" % self.option, self.dest])
+ rc = msger.run([self.mountcmd, "--bind", "-o", "remount,%s" % self.option, self.dest])
if rc != 0:
raise MountError("Bind-remounting '%s' failed" % self.dest)
self.mounted = True
return
if self.ismounted():
- subprocess.call([self.umountcmd, "-l", self.dest])
+ msger.run([self.umountcmd, "-l", self.dest])
self.mounted = False
class LoopbackMount:
def lounsetup(self):
if self.losetup:
- rc = subprocess.call([self.losetupcmd, "-d", self.loopdev])
+ rc = msger.run([self.losetupcmd, "-d", self.loopdev])
self.losetup = False
self.loopdev = None
self.loopdev = losetupOutput.split()[0]
- rc = subprocess.call([self.losetupcmd, self.loopdev, self.lofile])
+ rc = msger.run([self.losetupcmd, self.loopdev, self.lofile])
if rc != 0:
raise MountError("Failed to allocate loop device for '%s'" %
self.lofile)
device = losetupOutput.split()[0]
msger.debug("Losetup add %s mapping to %s" % (device, self.lofile))
- rc = subprocess.call([self.losetupcmd, device, self.lofile])
+ rc = msger.run([self.losetupcmd, device, self.lofile])
if rc != 0:
raise MountError("Failed to allocate loop device for '%s'" %
self.lofile)
if self.device is None:
return
msger.debug("Losetup remove %s" % self.device)
- rc = subprocess.call([self.losetupcmd, "-d", self.device])
+ rc = msger.run([self.losetupcmd, "-d", self.device])
self.device = None
def unmount(self):
if self.mounted:
msger.debug("Unmounting directory %s" % self.mountdir)
- synccmd = find_binary_path("sync")
- subprocess.call([synccmd]) # sync the data on this mount point
- rc = subprocess.call([self.umountcmd, "-l", self.mountdir])
+ msger.run('sync', True) # sync the data on this mount point
+ rc = msger.run([self.umountcmd, "-l", self.mountdir])
if rc == 0:
self.mounted = False
else:
if self.fstype:
args.extend(["-t", self.fstype])
- rc = subprocess.call(args)
+ rc = msger.run(args)
if rc != 0:
raise MountError("Failed to mount '%s' to '%s' with command '%s'. Retval: %s" %
(self.disk.device, self.mountdir, " ".join(args), rc))
if self.skipformat:
msger.debug("Skip filesystem format.")
return
- msger.debug("Formating %s filesystem on %s" % (self.fstype, self.disk.device))
- rc = subprocess.call([self.mkfscmd,
- "-F", "-L", self.fslabel,
- "-m", "1", "-b", str(self.blocksize),
- self.disk.device], stdout=sys.stdout,
- stderr=sys.stderr)
- # str(self.disk.size / self.blocksize)])
+
+ msger.info("Formating %s filesystem on %s" % (self.fstype, self.disk.device))
+ rc = msger.run([self.mkfscmd,
+ "-F", "-L", self.fslabel,
+ "-m", "1", "-b", str(self.blocksize),
+ self.disk.device]) # str(self.disk.size / self.blocksize)])
if rc != 0:
raise MountError("Error creating %s filesystem on disk %s" % (self.fstype,self.disk.device))
self.uuid = self.__parse_field(out, "Filesystem UUID")
msger.debug("Tuning filesystem on %s" % self.disk.device)
- subprocess.call([self.tune2fs, "-c0", "-i0", "-Odir_index",
- "-ouser_xattr,acl", self.disk.device],
- stdout=sys.stdout, stderr=sys.stderr)
+ msger.run([self.tune2fs, "-c0", "-i0", "-Odir_index", "-ouser_xattr,acl", self.disk.device])
def __resize_filesystem(self, size = None):
current_size = os.stat(self.disk.lofile)[stat.ST_SIZE]
DiskMount.mount(self, options)
def __fsck(self):
- msger.debug("Checking filesystem %s" % self.disk.lofile)
- subprocess.call(["/sbin/e2fsck", "-f", "-y", self.disk.lofile], stdout=sys.stdout, stderr=sys.stderr)
+ msger.info("Checking filesystem %s" % self.disk.lofile)
+ msger.run(["/sbin/e2fsck", "-f", "-y", self.disk.lofile])
def __get_size_from_filesystem(self):
dev_null = os.open("/dev/null", os.O_WRONLY)
msger.debug("Skip filesystem format.")
return
msger.debug("Formating %s filesystem on %s" % (self.fstype, self.disk.device))
- blah = [self.mkfscmd, "-n", self.fslabel, "-i", self.uuid, self.disk.device]
- rc = subprocess.call(blah)
+ rc = msger.run([self.mkfscmd, "-n", self.fslabel, "-i", self.uuid, self.disk.device])
if rc != 0:
raise MountError("Error creating %s filesystem on disk %s" % (self.fstype,self.disk.device))
msger.debug("Tuning filesystem on %s" % self.disk.device)
def __fsck(self):
msger.debug("Checking filesystem %s" % self.disk.lofile)
- subprocess.call([self.fsckcmd, "-y", self.disk.lofile])
+ msger.run([self.fsckcmd, "-y", self.disk.lofile])
def __get_size_from_filesystem(self):
return self.disk.size
# disable selinux, selinux will block write
if os.path.exists("/usr/sbin/setenforce"):
- subprocess.call(["/usr/sbin/setenforce", "0"])
+ msger.run(["/usr/sbin/setenforce", "0"])
def __parse_field(self, output, field):
for line in output.split(" "):
msger.debug("Skip filesystem format.")
return
msger.debug("Formating %s filesystem on %s" % (self.fstype, self.disk.device))
- rc = subprocess.call([self.mkfscmd, "-L", self.fslabel, self.disk.device])
+ rc = msger.run([self.mkfscmd, "-L", self.fslabel, self.disk.device])
if rc != 0:
raise MountError("Error creating %s filesystem on disk %s" % (self.fstype,self.disk.device))
def __fsck(self):
msger.debug("Checking filesystem %s" % self.disk.lofile)
- subprocess.call([self.btrfsckcmd, self.disk.lofile])
+ msger.run([self.btrfsckcmd, self.disk.lofile])
def __get_size_from_filesystem(self):
return self.disk.size
self.cowloop.device)
args = [self.dmsetupcmd, "create", self.__name, "--table", table]
- if subprocess.call(args) != 0:
+ if msger.run(args) != 0:
self.cowloop.cleanup()
self.imgloop.cleanup()
raise SnapshotError("Could not create snapshot device using: " +
return
time.sleep(2)
- rc = subprocess.call([self.dmsetupcmd, "remove", self.__name])
+ rc = msger.run([self.dmsetupcmd, "remove", self.__name])
if not ignore_errors and rc != 0:
raise SnapshotError("Could not remove snapshot device")
break
if not found:
msger.info("Loading %s..." % module)
- dev_null = os.open("/dev/null", os.O_WRONLY)
- modprobecmd = find_binary_path("modprobe")
- modprobe = subprocess.Popen([modprobecmd, module],
- stdout=dev_null, stderr=dev_null)
- os.waitpid(modprobe.pid, 0)
- os.close(dev_null)
+ msger.run(['modprobe', module], True)
def myurlgrab(url, filename, proxies, progress_obj = None):
g = URLGrabber()
if progress_obj is None:
progress_obj = TextProgress()
+
if url.startswith("file:///"):
file = url.replace("file://", "")
if not os.path.exists(file):
raise CreatorError("URLGrabber error: can't find file %s" % file)
- copycmd = find_binary_path("cp")
- subprocess.call([copycmd, "-f", file, filename])
+ msger.run(['cp', "-f", file, filename])
else:
try:
filename = g.urlgrab(url = url, filename = filename,
ssl_verify_host = False, ssl_verify_peer = False,
proxies = proxies, http_headers = (('Pragma', 'no-cache'),), progress_obj = progress_obj)
except URLGrabError, e:
- raise CreatorError("URLGrabber error: %s: %s" % (e, url))
- except:
raise CreatorError("URLGrabber error: %s" % url)
+
return filename
return get_uncompressed_data_from_url(url,filename_tmp,proxies)
def get_metadata_from_repos(repostrs, cachedir):
- if not cachedir:
- CreatorError("No cache dir defined.")
-
my_repo_metadata = []
for repostr in repostrs:
reponame = None
import os, sys, re
import rpm
-import subprocess
from mic import msger
class RPMInstallCallback:
def checkRpmIntegrity(bin_rpm, package):
argv = [bin_rpm, "--checksig", "--nogpg", package]
- dev_null = os.open("/dev/null", os.O_WRONLY)
- try:
- ret = subprocess.call(argv, stdout = dev_null, stderr = dev_null)
- finally:
- os.close(dev_null)
-
- return ret
+ return msger.run(argv, True)
def checkSig(ts, package):
""" Takes a transaction set and a package, check it's sigs,
return savepath
def _pager_file(savepath):
- import subprocess
if os.path.splitext(savepath)[1].upper() in ('.HTM', '.HTML'):
pagers = ('w3m', 'links', 'lynx', 'less', 'more')
file_showed = False
for pager in pagers:
+ cmd = "%s %s" % (pager, savepath)
try:
- subprocess.call([pager, savepath])
+ os.system(cmd)
except OSError:
continue
else:
total_count = len(dlpkgs)
cached_count = 0
- msger.info("\nChecking packages cache and packages integrity...")
+ msger.info("\nChecking packages cache and packages integrity ...")
for po in dlpkgs:
local = po.localPkg()
if not os.path.exists(local):
total_count = len(dlpkgs)
cached_count = 0
localpkgs = self.localpkgs.keys()
- msger.info("Checking packages cache and packages integrity...")
+ msger.info("Checking packages cache and packages integrity ...")
for po in dlpkgs:
""" Check if it is cached locally """
if po.name() in localpkgs:
msger.info("%d packages to be installed, %d packages gotten from cache, %d packages to be downloaded" % (total_count, cached_count, download_count))
try:
if download_count > 0:
- msger.info("Downloading packages...")
+ msger.info("Downloading packages ...")
self.downloadPkgs(dlpkgs, download_count)
self.installPkgs(dlpkgs)
#
import os
-import subprocess
import shutil
import tempfile
@classmethod
def do_pack(cls, base_on):
+ import subprocess
+
def __mkinitrd(instance):
kernelver = instance._get_kernel_versions().values()[0][0]
args = [ "/usr/libexec/mkliveinitrd", "/boot/initrd-%s.img" % kernelver, "%s" % kernelver ]
#
import os
-import subprocess
import shutil
import tempfile
@classmethod
def do_pack(cls, base_on):
+ import subprocess
+
def __mkinitrd(instance):
kernelver = instance._get_kernel_versions().values()[0][0]
args = [ "/usr/libexec/mkliveinitrd", "/boot/initrd-%s.img" % kernelver, "%s" % kernelver ]
#
import os
-import subprocess
import shutil
import re
import tempfile
@classmethod
def do_chroot(cls, target):
+ import subprocess
+
img = target
imgsize = misc.get_file_size(img) * 1024L * 1024L
partedcmd = fs_related.find_binary_path("parted")
args = ['dd', "if=%s" % srcloop.partitions[0]['device'], "of=%s" % image]
msger.info("`dd` image ...")
- rc = subprocess.call(args)
+ rc = msger.run(args)
srcloop.cleanup()
shutil.rmtree(srcmnt, ignore_errors = True)