本文整理汇总了Python中sh.cp方法的典型用法代码示例。如果您正苦于以下问题:Python sh.cp方法的具体用法?Python sh.cp怎么用?Python sh.cp使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sh
的用法示例。
在下文中一共展示了sh.cp方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: copy_files
# 需要导入模块: import sh [as 别名]
# 或者: from sh import cp [as 别名]
def copy_files(self):
# Pliki do skopiowania
files_to_copy = []
for root, dirnames, filenames in os.walk(self.source_mount):
for file in filenames:
files_to_copy.append(root + '/' + file)
# Modyfikacja ścieżki oraz kopiowanie plików
for index, file in enumerate(files_to_copy):
match = re.search("pyWinUSB\/\w{40}\/source\/(.*\/)", file)
dest_file = "/".join([
self.destination_mount
, match.group(1) if match else ""
])
# Tworzenie i kopiowanie
self.event_handler.on_progress(len(files_to_copy), index, file)
sh.mkdir(dest_file, "-p")
sh.cp(file, dest_file)
示例2: copy_files
# 需要导入模块: import sh [as 别名]
# 或者: from sh import cp [as 别名]
def copy_files(src_path, dst_path, *files):
"""
This helper function is aimed to copy files from a source path to a destination path.
:param src_path: absolute or relative source path
:param dst_path: absolute or relative destination path
:param files: tuples with the following format (source_filename, destination_filename)
"""
src_path, dst_path = __expand_folders(src_path, dst_path)
for file in files:
if isinstance(file, tuple):
src, dst = file
elif isinstance(file, string_types):
src, dst = 2 * [file]
else:
continue
src, dst = join(src_path, src), join(dst_path, dst)
if src != dst:
sh.cp(src, dst)
示例3: copy_folder
# 需要导入模块: import sh [as 别名]
# 或者: from sh import cp [as 别名]
def copy_folder(src_path, dst_path, includes=None):
"""
This helper function is aimed to copy an entire folder from a source path to a destination path.
:param src_path: absolute or relative source path
:param dst_path: absolute or relative destination path
:param includes: list of sub-folders and files to be included from the src_path and to be copied into dst_path
"""
src_path, dst_path = __expand_folders(src_path, dst_path)
if src_path != dst_path:
if includes is not None:
dst_path = join(dst_path, split(src_path)[-1])
if not exists(dst_path):
makedirs(dst_path)
for include in includes:
head, tail = split(include)
sub_dst_path = join(dst_path, head)
if not exists(sub_dst_path):
makedirs(sub_dst_path)
sh.cp('-R', join(src_path, include), sub_dst_path)
else:
sh.cp('-R', src_path, dst_path)
示例4: make_installer
# 需要导入模块: import sh [as 别名]
# 或者: from sh import cp [as 别名]
def make_installer(cfg):
""" """
print("Building installer...")
build_dir = 'build/{name}-{version}'.format(**cfg)
cfg.update({'build_dir': build_dir})
install_dir = '{build_dir}/usr/share/{name}'.format(**cfg)
desktop_dir = '{build_dir}/usr/share/applications/'.format(**cfg)
cfg.update({'install_dir': install_dir,
'desktop_dir': desktop_dir})
os.makedirs(build_dir)
with cd(build_dir):
os.makedirs('DEBIAN')
#: Write control
with open('DEBIAN/control', 'w') as f:
f.write(CONTROL_TEMPLATE.format(**cfg))
#: Write
os.makedirs(install_dir)
print(sh.cp('-R', glob('build/exe.linux-x86_64-3.5/*'), install_dir))
#: Make a simlink to /usr/local/bin
#print(sh.ln('-sf', '{install_dir}/{name}'.format(**cfg),
# '{install_dir}/usr/local/bin/{name}'.format(**cfg)))
#: Make a desktop icon /usr/share/applications
os.makedirs(desktop_dir)
print(sh.cp('{name}/res/declaracad.desktop'.format(**cfg), desktop_dir))
#: Prepare
try:
print(sh.chown('-R', 'root:root', build_dir))
except:
pass
#: Build it
deb = sh.Command('dpkg-deb')
print(deb('--build', build_dir))
示例5: bootstrap
# 需要导入模块: import sh [as 别名]
# 或者: from sh import cp [as 别名]
def bootstrap(source_app, appname):
# remove mypackage.app if it already exists
print('Copy Kivy.app/source.app if it exists')
if exists(appname):
print('{} already exists removing it...'.format(appname))
sh.rm('-rf', appname)
# check if Kivy.app exists and copy it
if not exists(source_app):
error("source app {} doesn't exist")
print('copying {} to {}'.format(source_app, appname))
sh.cp('-a', source_app, appname)