util.py 文件源码

python
阅读 29 收藏 0 点赞 0 评论 0

项目:OnlineSchemaChange 作者: facebookincubator 项目源码 文件源码
def rm(filename, sudo=False):
    """
    Remove a file on the disk, not us os.rm because we want to add timeout to
    the command. It's possible that the os call got hang when the disk has
    some problems
    """
    cmd_args = []
    if sudo:
        cmd_args += ['sudo']
    cmd_args += ['/bin/rm', filename]
    log.debug("Executing cmd: {}".format(str(cmd_args)))
    proc = subprocess.Popen(cmd_args, stdin=subprocess.PIPE,
                            stdout=subprocess.PIPE)
    try:
        (stdout, stderr) = proc.communicate(timeout=10)
    except subprocess.TimeoutExpired:
        proc.kill()
        raise OSCError('SHELL_TIMEOUT', {'cmd': ' '.join(cmd_args)})
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号