本文整理汇总了Python中mic.utils.runner.show函数的典型用法代码示例。如果您正苦于以下问题:Python show函数的具体用法?Python show怎么用?Python show使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了show函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: package
def package(self, destdir = "."):
"""Prepares the created image for final delivery.
In its simplest form, this method merely copies the install root to the
supplied destination directory; other subclasses may choose to package
the image by e.g. creating a bootable ISO containing the image and
bootloader configuration.
destdir -- the directory into which the final image should be moved;
this defaults to the current directory.
"""
self._stage_final_image()
if not os.path.exists(destdir):
fs.makedirs(destdir)
if self._img_compression_method:
if not self._img_name:
raise CreatorError("Image name not set.")
rc = None
img_location = os.path.join(self._outdir,self._img_name)
if self._img_compression_method == "bz2":
bzip2 = fs.find_binary_path('bzip2')
msger.info("Compressing %s with bzip2. Please wait..." \
% img_location)
rc = runner.show([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 = runner.show([bzip2, "-f", bootimg])
if rc:
raise CreatorError("Failed to compress image %s with "
"%s." \
% (bootimg,
self._img_compression_method))
if self._recording_pkgs:
self._save_recording_pkgs(destdir)
# For image formats with two or multiple image files, it will be
# better to put them under a directory
if self.image_format in ("raw", "vmdk", "vdi", "nand", "mrstnand"):
destdir = os.path.join(destdir, "%s-%s" \
% (self.name, self.image_format))
msger.debug("creating destination dir: %s" % destdir)
fs.makedirs(destdir)
# Ensure all data is flushed to _outdir
runner.quiet('sync')
for f in os.listdir(self._outdir):
shutil.move(os.path.join(self._outdir, f),
os.path.join(destdir, f))
self.outimage.append(os.path.join(destdir, f))
self.do_genchecksum(os.path.join(destdir, f))
开发者ID:csdb,项目名称:mic,代码行数:60,代码来源:baseimager.py
示例2: resize2fs
def resize2fs(fs, size):
resize2fs = find_binary_path("resize2fs")
if size == 0:
# it means to minimalize it
return runner.show([resize2fs, '-M', fs])
else:
return runner.show([resize2fs, fs, "%sK" % (size / 1024,)])
开发者ID:tizenorg,项目名称:tools.mic,代码行数:7,代码来源:fs_related.py
示例3: __create_subvolume_snapshots
def __create_subvolume_snapshots(self, p, pdisk):
import time
if self.snapshot_created:
return
""" Remount with subvolid=0 """
rc = runner.show([self.umountcmd, pdisk.mountdir])
if rc != 0:
raise MountError("Failed to umount %s" % pdisk.mountdir)
if pdisk.fsopts:
mountopts = pdisk.fsopts + ",subvolid=0"
else:
mountopts = "subvolid=0"
rc = runner.show([self.mountcmd, "-o", mountopts, pdisk.disk.device, pdisk.mountdir])
if rc != 0:
raise MountError("Failed to umount %s" % pdisk.mountdir)
""" Create all the subvolume snapshots """
snapshotts = time.strftime("%Y%m%d-%H%M")
for subvol in self.subvolumes:
subvolpath = pdisk.mountdir + "/" + subvol["subvol"]
snapshotpath = subvolpath + "_%s-1" % snapshotts
rc = runner.show([ self.btrfscmd, "subvolume", "snapshot", subvolpath, snapshotpath ])
if rc != 0:
raise MountError("Failed to create subvolume snapshot '%s' for '%s', return code: %d." % (snapshotpath, subvolpath, rc))
self.snapshot_created = True
开发者ID:saukko,项目名称:mic,代码行数:28,代码来源:partitionedfs.py
示例4: _install_syslinux
def _install_syslinux(self):
for name in self.__disks.keys():
loopdev = self.__disks[name].device
# Set MBR
mbrfile = "%s/usr/share/syslinux/" % self._instroot
if self._ptable_format == 'gpt':
mbrfile += "gptmbr.bin"
else:
mbrfile += "mbr.bin"
msger.debug("Installing syslinux bootloader '%s' to %s" % \
(mbrfile, loopdev))
rc = runner.show(['dd', 'if=%s' % mbrfile, 'of=' + loopdev])
if rc != 0:
raise MountError("Unable to set MBR to %s" % loopdev)
# Ensure all data is flushed to disk before doing syslinux install
runner.quiet('sync')
fullpathsyslinux = fs_related.find_binary_path("extlinux")
rc = runner.show([fullpathsyslinux,
"-i",
"%s/boot/extlinux" % self._instroot])
if rc != 0:
raise MountError("Unable to install syslinux bootloader to %s" \
% loopdev)
开发者ID:tizenorg,项目名称:tools.mic,代码行数:29,代码来源:raw.py
示例5: _install_syslinux
def _install_syslinux(self):
i = 0
for name in self.__disks.keys():
loopdev = self.__disks[name].device
i =i+1
msger.debug("Installing syslinux bootloader to %s" % loopdev)
(bootdevnum, rootdevnum, rootdev, prefix) = self._get_syslinux_boot_config()
#Set MBR
mbrsize = os.stat("%s/usr/share/syslinux/mbr.bin" % self._instroot)[stat.ST_SIZE]
rc = runner.show(['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")
rc = runner.quiet([parted, "-s", loopdev, "set", "%d" % (bootdevnum + 1), "boot", "on"])
#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 :-(
if rc != 0 and 1 == 0:
raise MountError("Unable to set bootable flag to %sp%d" % (loopdev, (bootdevnum + 1)))
#Ensure all data is flushed to disk before doing syslinux install
runner.quiet('sync')
fullpathsyslinux = fs_related.find_binary_path("extlinux")
rc = runner.show([fullpathsyslinux, "-i", "%s/boot/extlinux" % self._instroot])
if rc != 0:
raise MountError("Unable to install syslinux bootloader to %sp%d" % (loopdev, (bootdevnum + 1)))
开发者ID:xiaoqiang0,项目名称:mic,代码行数:33,代码来源:raw.py
示例6: _stage_final_image
def _stage_final_image(self):
if self.pack_to or self.shrink_image:
self._resparse(0)
else:
self._resparse()
for item in self._instloops:
imgfile = os.path.join(self.__imgdir, item['name'])
if item['fstype'] == "ext4":
runner.show('/sbin/tune2fs -O ^huge_file,extents,uninit_bg %s '
% imgfile)
if self.compress_image:
misc.compressing(imgfile, self.compress_image)
if not self.pack_to:
for item in os.listdir(self.__imgdir):
shutil.move(os.path.join(self.__imgdir, item),
os.path.join(self._outdir, item))
else:
msger.info("Pack all loop images together to %s" % self.pack_to)
dstfile = os.path.join(self._outdir, self.pack_to)
misc.packing(dstfile, self.__imgdir)
if self.pack_to:
mountfp_xml = os.path.splitext(self.pack_to)[0]
mountfp_xml = misc.strip_end(mountfp_xml, '.tar') + ".xml"
else:
mountfp_xml = self.name + ".xml"
# save mount points mapping file to xml
save_mountpoints(os.path.join(self._outdir, mountfp_xml),
self._instloops,
self.target_arch)
开发者ID:117111302,项目名称:poky,代码行数:33,代码来源:loop.py
示例7: unmount
def unmount(self):
if self.has_chroot_instance():
return
if self.ismounted():
runner.show([self.umountcmd, "-l", self.dest])
self.mounted = False
开发者ID:117111302,项目名称:poky,代码行数:7,代码来源:fs_related.py
示例8: _stage_final_image
def _stage_final_image(self):
try:
self.cmd_qemuimg = fs_related.find_binary_path('qemu-img')
except errors.CreatorError:
return LoopImageCreator._stage_final_image(self)
self._resparse()
imgfile = None
for item in self._instloops:
if item['mountpoint'] == '/':
if item['fstype'] == "ext4":
runner.show('/sbin/tune2fs -O ^huge_file,extents,uninit_bg %s'
% imgfile)
self.image_files.setdefault('partitions', {}).update(
{item['mountpoint']: item['label']})
imgfile = os.path.join(self._imgdir, item['name'])
if imgfile:
qemuimage = imgfile + ".x86"
runner.show("%s convert -O qcow2 %s %s"
% (self.cmd_qemuimg, imgfile, qemuimage))
os.unlink(imgfile)
os.rename(qemuimage, imgfile)
for item in os.listdir(self._imgdir):
shutil.move(os.path.join(self._imgdir, item),
os.path.join(self._outdir, item))
开发者ID:tizenorg,项目名称:tools.mic,代码行数:28,代码来源:qcow_plugin.py
示例9: __create_iso
def __create_iso(self, isodir):
iso = self._outdir + "/" + self.name + ".iso"
genisoimage = fs_related.find_binary_path("genisoimage")
args = [genisoimage,
"-J", "-r",
"-hide-rr-moved", "-hide-joliet-trans-tbl",
"-V", self.fslabel,
"-o", iso]
args.extend(self._get_mkisofs_options(isodir))
args.append(isodir)
if runner.show(args) != 0:
raise CreatorError("ISO creation failed!")
""" It should be ok still even if you haven't isohybrid """
isohybrid = None
try:
isohybrid = fs_related.find_binary_path("isohybrid")
except:
pass
if isohybrid:
args = [isohybrid, "-partok", iso ]
if runner.show(args) != 0:
raise CreatorError("Hybrid ISO creation failed!")
self.__implant_md5sum(iso)
开发者ID:nataliakoval,项目名称:mic,代码行数:29,代码来源:livecd.py
示例10: _stage_final_image
def _stage_final_image(self):
if self.compress_to:
self._resparse(0)
cfile_name = self.compress_to
mountfp_xml = os.path.splitext(cfile_name)[0] + ".xml"
for item in self._instloops:
imgfile = os.path.join(self.__imgdir, item['name'])
if item['fstype'] == "ext4":
runner.show('/sbin/tune2fs '
'-O ^huge_file,extents,uninit_bg %s ' \
% imgfile)
msger.info("Compress all loop images together to %s" % cfile_name)
dstfile = os.path.join(self._outdir, cfile_name)
if self.compress_imgdir_method == "tar":
misc.taring(dstfile, self.__imgdir)
elif self.compress_imgdir_method == "zip":
misc.ziping(dstfile, self.__imgdir)
else:
raise CreatorError("Unsupported compress type: %s" \
% self.compress_imgdir_method)
# save mount points mapping file to xml
save_mountpoints(os.path.join(self._outdir, mountfp_xml),
self._instloops,
self.target_arch)
else:
self._resparse()
for item in self._instloops:
shutil.move(os.path.join(self.__imgdir, item['name']),
os.path.join(self._outdir, item['name']))
开发者ID:sanyaade-embedded-systems,项目名称:mic,代码行数:35,代码来源:loop.py
示例11: _stage_final_image
def _stage_final_image(self):
if self.taring_to:
import tarfile
curdir = os.getcwd()
os.chdir(self.__imgdir)
self._resparse(0)
tarfile_name = self.taring_to
if not tarfile_name.endswith('.tar'):
tarfile_name += ".tar"
msger.info("Tar all loop images together to %s" % tarfile_name)
tar = tarfile.open(os.path.join(self._outdir, tarfile_name), 'w')
for item in self._instloops:
if item['fstype'] == "ext4":
runner.show('/sbin/tune2fs -O ^huge_file,extents,uninit_bg ' + item['name'])
tar.add(item['name'])
tar.close()
os.chdir(curdir)
else:
self._resparse()
for item in self._instloops:
shutil.move(os.path.join(self.__imgdir, item['name']), os.path.join(self._outdir, item['name']))
开发者ID:xiaoqiang0,项目名称:mic,代码行数:26,代码来源:loop.py
示例12: __create_subvolumes
def __create_subvolumes(self, p, pdisk):
""" Create all the subvolumes """
for subvol in self.subvolumes:
argv = [ self.btrfscmd, "subvolume", "create", pdisk.mountdir + "/" + subvol["subvol"]]
rc = runner.show(argv)
if rc != 0:
raise MountError("Failed to create subvolume '%s', return code: %d." % (subvol["subvol"], rc))
""" Set default subvolume, subvolume for "/" is default """
subvol = None
for subvolume in self.subvolumes:
if subvolume["mountpoint"] == "/" and p["disk"] == subvolume["disk"]:
subvol = subvolume
break
if subvol:
""" Get default subvolume id """
subvolid = self. __get_subvolume_id(pdisk.mountdir, subvol["subvol"])
""" Set default subvolume """
if subvolid != -1:
rc = runner.show([ self.btrfscmd, "subvolume", "set-default", "%d" % subvolid, pdisk.mountdir])
if rc != 0:
raise MountError("Failed to set default subvolume id: %d', return code: %d." % (subvolid, rc))
self.__create_subvolume_metadata(p, pdisk)
开发者ID:saukko,项目名称:mic,代码行数:27,代码来源:partitionedfs.py
示例13: myurlgrab
def myurlgrab(url, filename, proxies, progress_obj=None):
g = grabber.URLGrabber()
if progress_obj is None:
progress_obj = TextProgress()
if url.startswith("file:/"):
filepath = "/%s" % url.replace("file:", "").lstrip("/")
if not os.path.exists(filepath):
raise CreatorError("URLGrabber error: can't find file %s" % url)
if url.endswith(".rpm"):
return filepath
else:
# untouch repometadata in source path
runner.show(["cp", "-f", filepath, filename])
else:
try:
filename = g.urlgrab(
url=str(url),
filename=filename,
ssl_verify_host=False,
ssl_verify_peer=False,
proxies=proxies,
http_headers=(("Pragma", "no-cache"),),
quote=0,
progress_obj=progress_obj,
)
except grabber.URLGrabError, err:
msg = str(err)
if msg.find(url) < 0:
msg += " on %s" % url
raise CreatorError(msg)
开发者ID:Minipada,项目名称:Yocto-Edison,代码行数:32,代码来源:grabber.py
示例14: package
def package(self, destdir = "."):
ignores = ["/dev/fd",
"/dev/stdin",
"/dev/stdout",
"/dev/stderr",
"/etc/mtab"]
if not os.path.exists(destdir):
os.makedirs(destdir)
if self._recording_pkgs:
self._save_recording_pkgs(destdir)
if self._img_compression_method == None:
fsdir = os.path.join(destdir, self.name)
misc.check_space_pre_cp(self._instroot, destdir)
msger.info("Copying %s to %s ..." % (self._instroot, fsdir))
runner.show(['cp', "-af", self._instroot, fsdir])
for exclude in ignores:
if os.path.exists(fsdir + exclude):
os.unlink(fsdir + exclude)
self.outimage.append(fsdir)
elif self._img_compression_method == "tar.bz2":
dst = "%s/%s.tar.bz2" % (destdir, self.name)
msger.info("Creating %s (compressing %s with %s). Please wait..." \
% (dst, self._instroot, self._img_compression_method))
tar = find_binary_path('tar')
tar_cmdline = [tar, "--numeric-owner",
"--preserve-permissions",
"--preserve-order",
"--one-file-system",
"--directory",
self._instroot]
for ignore_entry in ignores:
if ignore_entry.startswith('/'):
ignore_entry = ignore_entry[1:]
tar_cmdline.append("--exclude=%s" % (ignore_entry))
tar_cmdline.extend(["-cjf", dst, "."])
rc = call(tar_cmdline)
if rc:
raise CreatorError("Failed compress image with tar.bz2. "
"Cmdline: %s" % (" ".join(tar_cmdline)))
self.outimage.append(dst)
else:
raise CreatorError("Compression method '%s' not supported for 'fs' "
"image format." % (self._img_compression_method))
开发者ID:sanyaade-embedded-systems,项目名称:mic,代码行数:57,代码来源:fs.py
示例15: __implant_md5sum
def __implant_md5sum(self, iso):
"""Implant an isomd5sum."""
if os.path.exists("/usr/bin/implantisomd5"):
implantisomd5 = "/usr/bin/implantisomd5"
else:
msger.warning("isomd5sum not installed; not setting up mediacheck")
implantisomd5 = ""
return
runner.show([implantisomd5, iso])
开发者ID:nataliakoval,项目名称:mic,代码行数:10,代码来源:livecd.py
示例16: __mount_subvolumes
def __mount_subvolumes(self, p, pdisk):
if self.skipformat:
""" Get subvolume info """
self.__get_subvolume_metadata(p, pdisk)
""" Set default mount options """
if len(self.subvolumes) != 0:
for subvol in self.subvolumes:
if subvol["mountpoint"] == p["mountpoint"] == "/":
opts = subvol["fsopts"].split(",")
for opt in opts:
if opt.strip().startswith("subvol="):
opts.remove(opt)
break
pdisk.fsopts = ",".join(opts)
break
if len(self.subvolumes) == 0:
""" Return directly if no subvolumes """
return
""" Remount to make default subvolume mounted """
rc = runner.show([self.umountcmd, pdisk.mountdir])
if rc != 0:
raise MountError("Failed to umount %s" % pdisk.mountdir)
rc = runner.show([self.mountcmd, "-o", pdisk.fsopts, pdisk.disk.device, pdisk.mountdir])
if rc != 0:
raise MountError("Failed to umount %s" % pdisk.mountdir)
for subvol in self.subvolumes:
if subvol["mountpoint"] == "/":
continue
subvolid = self. __get_subvolume_id(pdisk.mountdir, subvol["subvol"])
if subvolid == -1:
msger.debug("WARNING: invalid subvolume %s" % subvol["subvol"])
continue
""" Replace subvolume name with subvolume ID """
opts = subvol["fsopts"].split(",")
for opt in opts:
if opt.strip().startswith("subvol="):
opts.remove(opt)
break
opts.extend(["subvolrootid=0", "subvol=%s" % subvol["subvol"]])
fsopts = ",".join(opts)
subvol['fsopts'] = fsopts
mountpoint = self.mountdir + subvol['mountpoint']
makedirs(mountpoint)
rc = runner.show([self.mountcmd, "-o", fsopts, pdisk.disk.device, mountpoint])
if rc != 0:
raise MountError("Failed to mount subvolume %s to %s" % (subvol["subvol"], mountpoint))
subvol["mounted"] = True
开发者ID:saukko,项目名称:mic,代码行数:52,代码来源:partitionedfs.py
示例17: __check_btrfs
def __check_btrfs(self):
found = False
""" Need to load btrfs module to mount it """
load_module("btrfs")
for line in open("/proc/filesystems").xreadlines():
if line.find("btrfs") > -1:
found = True
break
if not found:
raise MountError("Your system can't mount btrfs filesystem, please make sure your kernel has btrfs support and the module btrfs.ko has been loaded.")
# disable selinux, selinux will block write
if os.path.exists("/usr/sbin/setenforce"):
runner.show(["/usr/sbin/setenforce", "0"])
开发者ID:tizenorg,项目名称:tools.mic,代码行数:14,代码来源:fs_related.py
示例18: mount
def mount(self):
for dev in self.disks.keys():
d = self.disks[dev]
d['disk'].create()
self.__format_disks()
self.__map_partitions()
self.__calculate_mountorder()
for mp in self.mountOrder:
p = None
for p1 in self.partitions:
if p1['mountpoint'] == mp:
p = p1
break
if mp == 'swap':
runner.show([self.mkswap, p['device']])
continue
rmmountdir = False
if p['mountpoint'] == "/":
rmmountdir = True
if p['fstype'] == "vfat" or p['fstype'] == "msdos":
myDiskMount = VfatDiskMount
elif p['fstype'] in ("ext2", "ext3", "ext4"):
myDiskMount = ExtDiskMount
elif p['fstype'] == "btrfs":
myDiskMount = BtrfsDiskMount
else:
raise MountError("Fail to support file system " + p['fstype'])
if p['fstype'] == "btrfs" and not p['fsopts']:
p['fsopts'] = "subvolid=0"
pdisk = myDiskMount(RawDisk(p['size'] * self.sector_size, p['device']),
self.mountdir + p['mountpoint'],
p['fstype'],
4096,
p['mountpoint'],
rmmountdir,
self.skipformat,
fsopts = p['fsopts'])
pdisk.mount(pdisk.fsopts)
if p['fstype'] == "btrfs" and p['mountpoint'] == "/":
if not self.skipformat:
self.__create_subvolumes(p, pdisk)
self.__mount_subvolumes(p, pdisk)
p['mount'] = pdisk
开发者ID:saukko,项目名称:mic,代码行数:49,代码来源:partitionedfs.py
示例19: generate_bmap
def generate_bmap(self):
""" Generate block map file for the image. The idea is that while disk
images we generate may be large (e.g., 4GiB), they may actually contain
only little real data, e.g., 512MiB. This data are files, directories,
file-system meta-data, partition table, etc. In other words, when
flashing the image to the target device, you do not have to copy all the
4GiB of data, you can copy only 512MiB of it, which is 4 times faster.
This function generates the block map file for an arbitrary image that
mic has generated. The block map file is basically an XML file which
contains a list of blocks which have to be copied to the target device.
The other blocks are not used and there is no need to copy them. """
if self.bmap_needed is None:
return
msger.info("Generating the map file(s)")
for name in self.__disks.keys():
image = self._full_path(self.__imgdir, name, self.__disk_format)
bmap_file = self._full_path(self._outdir, name, "bmap")
self.image_files.setdefault(name, {}).update({'bmap': \
os.path.basename(bmap_file)})
msger.debug("Generating block map file '%s'" % bmap_file)
bmaptoolcmd = misc.find_binary_path('bmaptool')
rc = runner.show([bmaptoolcmd, 'create', image, '-o', bmap_file])
if rc != 0:
raise CreatorError("Failed to create bmap file: %s" % bmap_file)
开发者ID:tizenorg,项目名称:tools.mic,代码行数:30,代码来源:raw.py
示例20: mount
def mount(self, options = None):
if self.mounted:
return
if not os.path.isdir(self.mountdir):
msger.debug("Creating mount point %s" % self.mountdir)
os.makedirs(self.mountdir)
self.rmdir = self.rmmountdir
self.__create()
msger.debug("Mounting %s at %s" % (self.disk.device, self.mountdir))
if options:
args = [ self.mountcmd, "-o", options, self.disk.device, self.mountdir ]
else:
args = [ self.mountcmd, self.disk.device, self.mountdir ]
if self.fstype:
args.extend(["-t", self.fstype])
rc = runner.show(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))
self.mounted = True
开发者ID:tizenorg,项目名称:tools.mic,代码行数:25,代码来源:fs_related.py
注:本文中的mic.utils.runner.show函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论