HdfsCLIPython 访问 HDFS 的 API 和命令行接口
HdfsCLI 是 Python 访问 HDFS 的 API 和命令行接口。
$ pip install hdfs
使用示例:
$ hdfscli --alias=dev
Welcome to the interactive HDFS python shell.
The HDFS client is available as `CLIENT`.
In [1]: CLIENT.list('data/')
Out[1]: ['1.json', '2.json']
In [2]: CLIENT.status('data/2.json')
Out[2]: {
'accessTime': 1439743128690,
'blockSize': 134217728,
'childrenNum': 0,
'fileId': 16389,
'group': 'supergroup',
'length': 2,
'modificationTime': 1439743129392,
'owner': 'drwho',
'pathSuffix': '',
'permission': '755',
'replication': 1,
'storagePolicy': 0,
'type': 'FILE'
}
In [3]: CLIENT.delete('data/2.json')
Out[3]: True评论
