当前位置: 首页>>代码示例>>Python>>正文


Python sh.rm方法代码示例

本文整理汇总了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 
开发者ID:XiaoMi,项目名称:mobile-ai-bench,代码行数:21,代码来源:device.py

示例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)) 
开发者ID:cloudify-cosmo,项目名称:packman,代码行数:20,代码来源:apt.py

示例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) 
开发者ID:XiaoMi,项目名称:mobile-ai-bench,代码行数:37,代码来源:benchmark.py

示例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 
开发者ID:XiaoMi,项目名称:mobile-ai-bench,代码行数:16,代码来源:ssh_device.py

示例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) 
开发者ID:gazetteerhk,项目名称:census_explorer,代码行数:16,代码来源:extract_data_from_xls.py

示例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) 
开发者ID:facebookresearch,项目名称:ParlAI,代码行数:35,代码来源:server.py

示例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)) 
开发者ID:facebookresearch,项目名称:ParlAI,代码行数:12,代码来源:server.py

示例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))) 
开发者ID:facebookresearch,项目名称:ParlAI,代码行数:13,代码来源:server_utils.py

示例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') 
开发者ID:Mati365,项目名称:pyWinUSB,代码行数:9,代码来源:creator.py

示例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) 
开发者ID:natashamjaques,项目名称:neural_chat,代码行数:37,代码来源:server_utils.py

示例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)) 
开发者ID:natashamjaques,项目名称:neural_chat,代码行数:12,代码来源:server_utils.py

示例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) 
开发者ID:datastax,项目名称:cstar_perf,代码行数:9,代码来源:utils.py

示例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 
开发者ID:dhondta,项目名称:rpl-attacks,代码行数:16,代码来源:helpers.py

示例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 
开发者ID:dhondta,项目名称:rpl-attacks,代码行数:14,代码来源:helpers.py

示例15: cleanup

# 需要导入模块: import sh [as 别名]
# 或者: from sh import rm [as 别名]
def cleanup():
    if exists('tmp/test_cli/'):
        sh.rm('-R', 'tmp/test_cli/') 
开发者ID:codelv,项目名称:enaml-native,代码行数:5,代码来源:test_cli.py


注:本文中的sh.rm方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。