判断本地文件是否存在
def local_exist(file_path):
"""
判断本地文件是否存在
:return: 布尔值
"""
with settings(warn_only=True):
result=local("[ -e '"+file_path+"' ]")
print result.return_code
if result.return_code == 0:
return True
else:
return False
判断远端文件是否存在
def remote_exist(file_path):
"""
判断远端文件是否存在
:return: 布尔值
"""
if int(run(" [ -e "+file_path+" ] && echo 11 || echo 10")) == 11:
return True
else:
return False