1234567891011121314151617181920212223242526 |
- '''
- Created on 2019年10月24日
- @author: User
- '''
- import pyhdfs
- import os
- import codecs
- fs = pyhdfs.HdfsClient(hosts="192.168.48.178,50070",user_name='root1')
- print(fs.get_home_directory())
- print(fs.get_active_namenode())
- file = fs.get_home_directory()+"/ContentExtract.rar"
- localfile = os.path.abspath("./ContentExtract.rar")
- print(localfile)
- print(fs.exists(file))
- if not os.path.exists(localfile):
- with codecs.open(localfile,"w") as f:
- f.flush()
- #fs.copy_to_local(file,localfile)
- fs.delete(file)
- fs.copy_from_local(localfile,file)
- print(fs.listdir(fs.get_home_directory()))
- print(fs.exists(file))
|