本文整理汇总了Python中util.subp函数的典型用法代码示例。如果您正苦于以下问题:Python subp函数的具体用法?Python subp怎么用?Python subp使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了subp函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: _run_rsync
def _run_rsync(self):
""" run rsync to pull out the rootfs /etc/ dir
(later it is re-mounted inside the container so RHI can edit
any needed files """
# rsync -aqPS ${IMAGE}/etc .
if os.path.exists(self.tmp_image_dir + "etc/"):
cmd = ['rsync', '-aqPS', self.tmp_image_dir + "etc/", "/home/temp_etc/"]
r = util.subp(cmd)
if r.return_code != 0:
raise EmulatorError('Rysnc unable to copy files: %s ' % cmd)
# FIXME for some reason, some versions of RHEL containers don't have these dirs?
# odd right?
if not os.path.exists("/home/temp_etc/pki"):
cmd = ['mkdir', '/home/temp_etc/etc/pki']
r = util.subp(cmd)
if r.return_code != 0:
raise EmulatorError('Unable to make temporary directory: %s ' % cmd)
if not os.path.exists("/home/temp_etc/pki/consumer"):
cmd = ['mkdir', '/home/temp_etc/pki/consumer']
r = util.subp(cmd)
if r.return_code != 0:
raise EmulatorError('Unable to make temporary directory: %s ' % cmd)
开发者ID:ajcollins0,项目名称:insights-container,代码行数:25,代码来源:emulator.py
示例2: _remove_var_tmp_dir
def _remove_var_tmp_dir(self):
""" remove the old location of where RHAI's output was stored """
cmd = ['rm', '-rf', self.vartmp_dir]
r = util.subp(cmd)
if r.return_code != 0:
print "vartmp dir did not remove"
开发者ID:lphiri,项目名称:insights-docker,代码行数:7,代码来源:emulator.py
示例3: remove_image
def remove_image(self, image_id):
""" force removes image image_id """
cmd = ['docker', 'rmi', '-f', image_id]
out = util.subp(cmd)
if out.return_code != 0:
print "image was not deleted"
开发者ID:lphiri,项目名称:insights-docker,代码行数:7,代码来源:docker_client.py
示例4: _copy_launcher
def _copy_launcher(self):
""" copy the launching script into the rootfs/mnt dir """
cmd = ['cp', './launcher.sh', self.tmp_image_dir + '/mnt/']
r = util.subp(cmd)
if r.return_code != 0:
print "could not copy launcher!"
开发者ID:lphiri,项目名称:insights-docker,代码行数:7,代码来源:emulator.py
示例5: getDmsetupLs
def getDmsetupLs():
cmd = ['dmsetup', 'ls']
r = util.subp(cmd)
if r.return_code != 0:
print r.stderr
return -1
return r.stdout
开发者ID:Prosper95,项目名称:insights-client,代码行数:7,代码来源:dmsetupWrap.py
示例6: _get_fs
def _get_fs(thin_pathname):
"""
Returns the file system type (xfs, ext4) of a given device
"""
cmd = ['lsblk', '-o', 'FSTYPE', '-n', thin_pathname]
fs_return = util.subp(cmd)
return fs_return.stdout.strip()
开发者ID:yonglehou,项目名称:atomic,代码行数:7,代码来源:mount.py
示例7: unmount_path
def unmount_path(path):
"""
Unmounts the directory specified by path.
"""
r = util.subp(['umount', path])
if r.return_code != 0:
raise ValueError(r.stderr)
开发者ID:yonglehou,项目名称:atomic,代码行数:7,代码来源:mount.py
示例8: chroot_and_run
def chroot_and_run(self):
""" give the chroot cmda and run the launcher script in the rootfs """
cmd = ['chroot', self.tmp_image_dir, '/mnt/launcher.sh']
r = util.subp(cmd)
if r.return_code != 0:
raise EmulatorError('Unable to start Insights Script: %s ' % cmd)
开发者ID:ajcollins0,项目名称:insights-container,代码行数:7,代码来源:emulator.py
示例9: _remove_thin_device
def _remove_thin_device(name):
"""
Destroys a thin device via subprocess call.
"""
r = util.subp(['dmsetup', 'remove', name])
if r.return_code != 0:
raise MountError('Could not remove thin device:\n' + r.stderr)
开发者ID:yonglehou,项目名称:atomic,代码行数:7,代码来源:mount.py
示例10: _copy_resolve_conf
def _copy_resolve_conf(self):
""" copy the host machines resolve.conf and put it into the rootfs' /etc/ dir """
cmd = ['cp', '/etc/resolv.conf', self.tmp_image_dir + '/etc/']
r = util.subp(cmd)
if r.return_code != 0:
raise EmulatorError('Unable to copy file: %s ' % cmd)
开发者ID:ajcollins0,项目名称:insights-container,代码行数:7,代码来源:emulator.py
示例11: _copy_launcher
def _copy_launcher(self):
""" copy the launching script into the rootfs/mnt dir """
cmd = ['cp', '/home/insights-docker/launcher.sh', self.tmp_image_dir + '/mnt/']
r = util.subp(cmd)
if r.return_code != 0:
raise EmulatorError('Unable to copy file: %s ' % cmd)
开发者ID:ajcollins0,项目名称:insights-container,代码行数:7,代码来源:emulator.py
示例12: inspect
def inspect(self, obj_id):
# returns dict representation of "docker inspect ID"
cmd = ['docker', 'inspect', obj_id]
r = util.subp(cmd)
if r.return_code != 0:
raise Exception('Unable to inspect object: %s' % obj_id)
return json.loads(r.stdout)
开发者ID:redhataccess,项目名称:insights-client,代码行数:7,代码来源:docker_wrap.py
示例13: _mount_overlay
def _mount_overlay(self, identifier):
"""
OverlayFS mount backend.
"""
cid = self._identifier_as_cid(identifier)
cinfo = self.client.inspect_container(cid)
ld, ud, wd = '', '', ''
try:
ld = cinfo['GraphDriver']['Data']['lowerDir']
ud = cinfo['GraphDriver']['Data']['upperDir']
wd = cinfo['GraphDriver']['Data']['workDir']
except:
ld, ud, wd = DockerMount._no_gd_api_overlay(cid)
options = ['ro', 'lowerdir=' + ld, 'upperdir=' + ud, 'workdir=' + wd]
optstring = ','.join(options)
cmd = ['mount', '-t', 'overlay', '-o', optstring, 'overlay',
self.mountpoint]
status = util.subp(cmd)
if status.return_code != 0:
self._cleanup_container(cinfo)
raise MountError('Failed to mount OverlayFS device.\n%s' %
status.stderr.decode(sys.getdefaultencoding()))
return cid
开发者ID:matysek,项目名称:insights-client,代码行数:27,代码来源:mount.py
示例14: chroot_and_run
def chroot_and_run(self):
""" give the chroot cmda and run the launcher script in the rootfs """
cmd = ['chroot', self.tmp_image_dir, '/mnt/launcher.sh']
r = util.subp(cmd)
if r.return_code != 0:
print "could not chroot and run!"
sys.exit()
开发者ID:lphiri,项目名称:insights-docker,代码行数:8,代码来源:emulator.py
示例15: commit
def commit(self, container):
""" commits the container into a new image with the given tag """
cmd = ['docker', 'commit', '-c', "ENV _RHAI_TEMP_CONTAINER=True", container]
out = util.subp(cmd)
if out.return_code != 0:
print "image was not commited"
return out.stdout.strip()
开发者ID:lphiri,项目名称:insights-docker,代码行数:8,代码来源:docker_client.py
示例16: remove_old_data
def remove_old_data():
""" deleted old output """
temp_dir = "/var/tmp/docker/"
cmd = ['rm', '-rf', temp_dir]
r = util.subp(cmd)
if r.return_code != 0:
raise ValueError(str("Unable to remove directory %s."% temp_dir))
开发者ID:ajcollins0,项目名称:insights-container,代码行数:8,代码来源:__init__.py
示例17: remove_old_data
def remove_old_data():
""" deleted old output """
import util
cmd = ['rm', '-rf', "/var/tmp/docker/"]
r = util.subp(cmd)
if r.return_code != 0:
print "old data was not deleted"
开发者ID:lphiri,项目名称:insights-docker,代码行数:8,代码来源:__init__.py
示例18: inspect
def inspect(self, obj_id):
""" returns a dict of the inspection of a container or image """
cmd = ['docker', 'inspect', obj_id]
out = util.subp(cmd)
trim_out = out.stdout.strip()
ret = json.loads(trim_out[2:-2])
return ret
开发者ID:lphiri,项目名称:insights-docker,代码行数:8,代码来源:docker_client.py
示例19: create_dirs
def create_dirs(self):
""" creates a dir of every entry in self.dir_list """
for d in self.dir_list:
if not os.path.exists(d):
cmd = ['mkdir', d]
r = util.subp(cmd)
if r.return_code != 0:
raise EmulatorError('Not able to mount directory %s' % d )
开发者ID:ajcollins0,项目名称:insights-container,代码行数:9,代码来源:emulator.py
示例20: create_dirs
def create_dirs(self):
""" creates a dir of every entry in self.dir_list """
for d in self.dir_list:
if not os.path.exists(d):
cmd = ['mkdir', d]
r = util.subp(cmd)
if r.return_code != 0:
print "temp dirs did not mount"
开发者ID:lphiri,项目名称:insights-docker,代码行数:9,代码来源:emulator.py
注:本文中的util.subp函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论