def test_filesystem(self): hfile = Hfile(hostname, port, path, mode='w') hfile.close() fs = Hfilesystem(hostname, port) self.assertTrue(fs.exists(path)) self.assertFalse(fs.exists(path + 'doesnotexist')) self.assertTrue(fs.rename(path, path + 'renamed')) self.assertTrue(fs.delete(path + 'renamed')) self.assertFalse(fs.delete(path))
hfile.write(line) # And close them. fh.close() hfile.close() # Let's read local_path into memory for comparison. motd = open(local_path).read() # Now let's read the data back hfile = Hfile(hostname, port, hdfs_path) # With an iterator data_read_from_hdfs = '' for line in hfile: data_read_from_hdfs += line print motd == data_read_from_hdfs # All at once data_read_from_hdfs = hfile.read() print motd == data_read_from_hdfs hfile.close() # Hopefully you have enough info to get started! from hdfs.hfilesystem import Hfilesystem hfs = Hfilesystem(hostname, port) print hfs.getHosts(hdfs_path, 0, 1)
def test_mkdir(self): fs = Hfilesystem(hostname, port) self.assertTrue(fs.mkdir(path)) self.assertTrue(fs.delete(path))