我想使用 snakebite 来检查 hdfs 目录中是否存在文件,如果不存在则创建。我正在关注 touchz
here 上的文档并像这样使用它:
def createFile(client):
if client.test("/user/test/sample.txt", exists=True):
print "file exists"
else:
print "file not exist, create file"
print client.touchz(["/user/test/sample.txt"])
client = Client(remote_host, 8020, use_trash=False)
createFile(client)
但是当我去检查时,我没有在 remote_host:/user/test/
中看到 sample.txt
但是我在使用 hadoop fs -touchz remote_host:/user/test/sample.txt
如何使用 snakebite 的 touchz
?
最佳答案
snakebite 的 touchz
生成一个生成器,它在您迭代这些值之前不会执行任何操作。
因此,您要么必须遍历 touchz
的返回值,要么对其调用 list()
。
关于python - Snakebite HDFS touchz 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40307518/