import subprocess
def run_cmd(args_list):
print('Running system command: {0}'.format(' '.join(args_list)))
proc = subprocess.Popen(args_list, stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
proc.communicate()
return proc.returncode
cmd = ['hadoop', 'fs', '-test', '-e', hdfs_file_path]
code = run_cmd(cmd)
if code:
print 'file not exist'
当我发出这个命令来查看文件是否存在于HDFS中时,它向我抛出以下错误:
^{pr2}$如何解决这个问题?在
我将使用api而不是调用子进程。为此,最好使用api,例如spotify创建的snakebite。此示例检查给定文件夹中是否存在文件:
相关问题 更多 >
编程相关推荐