本文整理匯總了Python中sh.rm方法的典型用法代碼示例。如果您正苦於以下問題:Python sh.rm方法的具體用法?Python sh.rm怎麽用?Python sh.rm使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類sh
的用法示例。
在下文中一共展示了sh.rm方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: pull
# 需要導入模塊: import sh [as 別名]
# 或者: from sh import rm [as 別名]
def pull(self, src_path, dst_path='.'):
if self.system == SystemType.android:
sh_commands.adb_pull(src_path, dst_path, self.address)
elif self.system == SystemType.arm_linux:
if os.path.isdir(dst_path):
exist_file = dst_path + '/' + src_path.split('/')[-1]
if os.path.exists(exist_file):
sh.rm('-rf', exist_file)
elif os.path.exists(dst_path):
sh.rm('-f', dst_path)
try:
sh.scp('-r',
'%s@%s:%s' % (self.username,
self.address,
src_path),
dst_path)
except sh.ErrorReturnCode_1 as e:
six.print_('Error msg {}'.format(e), file=sys.stderr)
return
示例2: download
# 需要導入模塊: import sh [as 別名]
# 或者: from sh import rm [as 別名]
def download(self, reqs, sources_path):
"""downloads component requirements
:param list reqs: list of requirements to download
:param sources_path: path to download requirements to
"""
for req in reqs:
# TODO: (TEST) add an is-package-installed check. if it is
# TODO: (TEST) run apt-get install --reinstall instead of apt-get
# TODO: (TEST) install.
# TODO: (IMPRV) try http://askubuntu.com/questions/219828/getting-deb-package-dependencies-for-an-offline-ubuntu-computer-through-windows # NOQA
# TODO: (IMPRV) for downloading requirements
lgr.debug('Downloading {0} to {1}...'.format(req, sources_path))
o = sh.apt_get.install('-y', req, '-d', o='dir::cache={0}'.format(
sources_path), _iter=True)
for line in o:
lgr.debug(line)
sh.rm('{0}/*.bin'.format(sources_path))
示例3: run_on_device
# 需要導入模塊: import sh [as 別名]
# 或者: from sh import rm [as 別名]
def run_on_device(target_device,
target_abi,
push_list,
executors,
target,
device_types,
host_bin_path,
bin_name,
input_dir,
benchmark_option,
benchmark_list,
result_files,
):
props = target_device.get_props()
product_model = props["ro.product.model"]
result_path = os.path.join(
FLAGS.output_dir, product_model + "_" + target_device.target_soc
+ "_" + target_abi + "_" + "result.txt")
sh.rm("-rf", result_path)
device_bench_path = target_device.get_bench_path()
target_device.exec_command("mkdir -p %s" % device_bench_path)
bench_engine.push_all_models(target_device, device_bench_path, push_list)
for executor in executors:
avail_device_types = \
target_device.get_available_device_types(device_types, target_abi,
executor)
bench_engine.bazel_build(target, target_abi, executor,
avail_device_types)
bench_engine.bench_run(
target_abi, target_device, host_bin_path, bin_name,
benchmark_option, input_dir, FLAGS.run_interval,
FLAGS.num_threads, FLAGS.max_time_per_lock,
benchmark_list, executor, avail_device_types, device_bench_path,
FLAGS.output_dir, result_path, product_model)
result_files.append(result_path)
示例4: pull
# 需要導入模塊: import sh [as 別名]
# 或者: from sh import rm [as 別名]
def pull(self, src_path, dst_path='.'):
if os.path.isdir(dst_path):
exist_file = dst_path + '/' + src_path.split('/')[-1]
if os.path.exists(exist_file):
sh.rm('-rf', exist_file)
elif os.path.exists(dst_path):
sh.rm('-f', dst_path)
try:
sh.scp('-r',
'%s@%s:%s' % (self.username, self.address, src_path),
dst_path)
except sh.ErrorReturnCode_1 as e:
six.print_('Error msg {}'.format(e), file=sys.stderr)
return
示例5: main
# 需要導入模塊: import sh [as 別名]
# 或者: from sh import rm [as 別名]
def main():
logger.info('Start to parse individual xls files')
sh.rm('-rf', OUTPUT_PREFIX)
sh.mkdir('-p', OUTPUT_PREFIX)
files = [fn for fn in sh.ls(INPUT_PREFIX).split()]
files = [fn for fn in files if fn.endswith('.xlsx')]
# Extract xls to JSON
pool = multiprocessing.Pool()
pool.map(process_one_file, files)
# Translation
logger.info('Start to generate translation dicts')
gen_translation(files)
示例6: setup_local_server
# 需要導入模塊: import sh [as 別名]
# 或者: from sh import rm [as 別名]
def setup_local_server(task_name):
global server_process
print("Local Server: Collecting files...")
server_source_directory_path = os.path.join(core_dir, server_source_directory_name)
local_server_directory_path = os.path.join(
core_dir, '{}_{}'.format(local_server_directory_name, task_name)
)
# Delete old server files
sh.rm(shlex.split('-rf ' + local_server_directory_path))
# Copy over a clean copy into the server directory
shutil.copytree(server_source_directory_path, local_server_directory_path)
print("Local: Starting server...")
os.chdir(local_server_directory_path)
packages_installed = subprocess.call(['npm', 'install'])
if packages_installed != 0:
raise Exception(
'please make sure npm is installed, otherwise view '
'the above error for more info.'
)
server_process = subprocess.Popen(['node', 'server.js'])
time.sleep(1)
print('Server running locally with pid {}.'.format(server_process.pid))
host = input('Please enter the public server address, like https://hostname.com: ')
port = input('Please enter the port given above, likely 3000: ')
return '{}:{}'.format(host, port)
示例7: delete_local_server
# 需要導入模塊: import sh [as 別名]
# 或者: from sh import rm [as 別名]
def delete_local_server(task_name):
global server_process
print('Terminating server')
server_process.terminate()
server_process.wait()
print('Cleaning temp directory')
local_server_directory_path = os.path.join(
core_dir, '{}_{}'.format(local_server_directory_name, task_name)
)
sh.rm(shlex.split('-rf ' + local_server_directory_path))
示例8: delete_local_server
# 需要導入模塊: import sh [as 別名]
# 或者: from sh import rm [as 別名]
def delete_local_server(task_name):
global server_process
print('Terminating server')
server_process.terminate()
server_process.wait()
print('Cleaning temp directory')
local_server_directory_path = os.path.join(
parent_dir, '{}_{}'.format(local_server_directory_name, task_name)
)
sh.rm(shlex.split('-rf {}'.format(local_server_directory_path)))
示例9: close_stream
# 需要導入模塊: import sh [as 別名]
# 或者: from sh import rm [as 別名]
def close_stream(self):
""" Zamykanie urządzenia i kasowanie plików tymczasowych
"""
if self.source_mount is not None:
sh.sync()
sh.umount(self.source_mount, self.destination_mount)
sh.rm(self.mount_folder, '-rf')
示例10: setup_local_server
# 需要導入模塊: import sh [as 別名]
# 或者: from sh import rm [as 別名]
def setup_local_server(task_name):
global server_process
print("Local Server: Collecting files...")
server_source_directory_path = os.path.join(
parent_dir, server_source_directory_name
)
local_server_directory_path = os.path.join(
parent_dir, '{}_{}'.format(local_server_directory_name, task_name)
)
# Delete old server files
sh.rm(shlex.split('-rf ' + local_server_directory_path))
# Copy over a clean copy into the server directory
shutil.copytree(server_source_directory_path, local_server_directory_path)
print("Local: Starting server...")
os.chdir(local_server_directory_path)
packages_installed = subprocess.call(['npm', 'install'])
if packages_installed != 0:
raise Exception(
'please make sure npm is installed, otherwise view '
'the above error for more info.'
)
server_process = subprocess.Popen(['node', 'server.js'])
time.sleep(1)
print('Server running locally with pid {}.'.format(server_process.pid))
host = input('Please enter the public server address, like https://hostname.com: ')
port = input('Please enter the port given above, likely 3000: ')
return '{}:{}'.format(host, port)
示例11: delete_local_server
# 需要導入模塊: import sh [as 別名]
# 或者: from sh import rm [as 別名]
def delete_local_server(task_name):
global server_process
print('Terminating server')
server_process.terminate()
server_process.wait()
print('Cleaning temp directory')
local_server_directory_path = os.path.join(
parent_dir, '{}_{}'.format(local_server_directory_name, task_name)
)
sh.rm(shlex.split('-rf ' + local_server_directory_path))
示例12: clean_directory
# 需要導入模塊: import sh [as 別名]
# 或者: from sh import rm [as 別名]
def clean_directory(directory):
"""Remove all files in a directory"""
for filename in os.listdir(directory):
f = os.path.join(directory, filename)
if os.path.isfile(f):
sh.rm(f)
示例13: remove_files
# 需要導入模塊: import sh [as 別名]
# 或者: from sh import rm [as 別名]
def remove_files(path, *files):
"""
This helper function is aimed to remove specified files. If a file does not exist,
it fails silently.
:param path: absolute or relative source path
:param files: filenames of files to be removed
"""
path = __expand_folders(path)
for file in files:
try:
sh.rm(join(path, file))
except sh.ErrorReturnCode_1:
pass
示例14: remove_folder
# 需要導入模塊: import sh [as 別名]
# 或者: from sh import rm [as 別名]
def remove_folder(path):
"""
This helper function is aimed to remove an entire folder. If the folder does not exist,
it fails silently.
:param path: absolute or relative source path
"""
path = __expand_folders(path)
try:
sh.rm('-r', path)
except sh.ErrorReturnCode_1:
pass
示例15: cleanup
# 需要導入模塊: import sh [as 別名]
# 或者: from sh import rm [as 別名]
def cleanup():
if exists('tmp/test_cli/'):
sh.rm('-R', 'tmp/test_cli/')