本文整理汇总了Python中mrjob.fs.hadoop.HadoopFilesystem.copy_from_local方法的典型用法代码示例。如果您正苦于以下问题:Python HadoopFilesystem.copy_from_local方法的具体用法?Python HadoopFilesystem.copy_from_local怎么用?Python HadoopFilesystem.copy_from_local使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mrjob.fs.hadoop.HadoopFilesystem
的用法示例。
在下文中一共展示了HadoopFilesystem.copy_from_local方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: HadoopFSTestCase
# 需要导入模块: from mrjob.fs.hadoop import HadoopFilesystem [as 别名]
# 或者: from mrjob.fs.hadoop.HadoopFilesystem import copy_from_local [as 别名]
#.........这里部分代码省略.........
self.assertItemsEqual(list(self.fs.ls('hdfs:///')), ['hdfs:///foo bar'])
def test_double_space(self):
self.make_hdfs_file('foo bar')
self.assertItemsEqual(list(self.fs.ls('hdfs:///')), ['hdfs:///foo bar'])
def test_cat_uncompressed(self):
# mockhadoop doesn't support compressed files, so we won't test for it.
# this is only a sanity check anyway.
self.make_hdfs_file('data/foo', 'foo\nfoo\n')
remote_path = self.fs.path_join('hdfs:///data', 'foo')
self.assertEqual(list(self.fs._cat_file(remote_path)),
['foo\n', 'foo\n'])
def test_write_str(self):
path = 'hdfs:///write-test-str'
content = 'some content!'
self.fs.write(path, content)
self.assertEqual("".join(self.fs.cat(path)), content)
def test_write_file(self):
path = 'hdfs:///write-test-fileobj'
content = StringIO('some content!')
self.fs.write(path, content)
self.assertEqual("".join(self.fs.cat(path)), content.getvalue())
def test_write_overwrite(self):
self.make_hdfs_file('existing', 'this file already exists')
self.assertRaises(OSError, self.fs.write, 'hdfs:///existing',
'can not overwrite')
def test_copy_from_local(self):
content = 'file filler'
dst = 'hdfs:///hadoop-copy'
src = self.makefile('local-source', content)
self.fs.copy_from_local(dst, src)
self.assertEqual("".join(self.fs.cat(dst)), content)
def test_copy_from_local_override(self):
src = self.makefile('local-source', 'source')
self.make_hdfs_file('existing', 'this file already exists')
self.assertRaises(OSError, self.fs.copy_from_local,
'hdfs:///existing', src)
def test_du(self):
self.make_hdfs_file('data1', 'abcd')
self.make_hdfs_file('more/data2', 'defg')
self.make_hdfs_file('more/data3', 'hijk')
self.assertEqual(self.fs.du('hdfs:///'), 12)
self.assertEqual(self.fs.du('hdfs:///data1'), 4)
self.assertEqual(self.fs.du('hdfs:///more'), 8)
self.assertEqual(self.fs.du('hdfs:///more/*'), 8)
self.assertEqual(self.fs.du('hdfs:///more/data2'), 4)
self.assertEqual(self.fs.du('hdfs:///more/data3'), 4)
def test_mkdir(self):
self.fs.mkdir('hdfs:///d')
local_path = os.path.join(self.tmp_dir, 'mock_hdfs_root', 'd')
self.assertEqual(os.path.isdir(local_path), True)
def test_path_exists_no(self):
path = 'hdfs:///f'