Exemplo n.º 1
0
 def test_stat_file(self):
     _stdout = "Found 1 items\n" "-rwxr-xr-x   3 vagrant vagrant   65652975 2014-10-01 09:12 /user/vagrant/dmode.txt"
     with patch(HDFS_IS_DIR_FUNC) as mock_isdir:
         mock_isdir.return_value = False
         stat = hdfs_client.stat(
             "/user/vagrant/dmode.txt",
             executor=lambda cmd, *args: self._assert_command_generation(
                 "hadoop fs -ls /user/vagrant/dmode.txt", stdout=_stdout
             )(cmd, *args),
         )
         self.assertListEqual(
             ["-rwxr-xr-x", "3", "vagrant", "vagrant", "65652975", "2014-10-01", "09:12", "/user/vagrant/dmode.txt"],
             stat,
         )
Exemplo n.º 2
0
 def test_stat_file(self):
     _stdout = (
         "Found 1 items\n"
         "-rwxr-xr-x   3 vagrant vagrant   65652975 2014-10-01 09:12 /user/vagrant/dmode.txt"
     )
     with patch(HDFS_IS_DIR_FUNC) as mock_isdir:
         mock_isdir.return_value = False
         stat = hdfs_client.stat(
             "/user/vagrant/dmode.txt",
             executor=lambda cmd, *args: self._assert_command_generation(
                 "hadoop fs -ls /user/vagrant/dmode.txt", stdout=_stdout)
             (cmd, *args))
         self.assertListEqual([
             "-rwxr-xr-x", "3", "vagrant", "vagrant", "65652975",
             "2014-10-01", "09:12", "/user/vagrant/dmode.txt"
         ], stat)
Exemplo n.º 3
0
 def test_stat_dir(self):
     _stdout = (
         "Found 4 items\n"
         "drwxr-xr-x   - hbase hbase               0 2014-10-01 08:50 /hbase\n"
         "drwxrwxr-x   - solr  solr                0 2014-10-01 08:51 /solr\n"
         "drwxrwxrwt   - hdfs  supergroup          0 2014-10-03 14:13 /tmp\n"
         "drwxr-xr-x   - hdfs  supergroup          0 2014-10-01 09:11 /user"
     )
     with patch(HDFS_IS_DIR_FUNC) as mock_isdir:
         mock_isdir.return_value = True
         stat = hdfs_client.stat(
             "/user",
             executor=lambda cmd, *args: self._assert_command_generation(
                 os.path.join("hadoop fs -ls /user", ".."), stdout=_stdout
             )(cmd, *args),
         )
         self.assertListEqual(["drwxr-xr-x", "-", "hdfs", "supergroup", "0", "2014-10-01", "09:11", "/user"], stat)
Exemplo n.º 4
0
 def get_description(self):
     """
     Gets metadata of file at the given path
     :return: FileDescriptor
     """
     permissions, number_of_replicas, userid, groupid, filesize, modification_date, modification_time, filename = tuple(
         fs.stat(self.path))
     _file_description = FileDescriptor(
         name=self.path,
         update_date=datetime.strptime(
             " ".join([modification_date, modification_time[:5]]),
             "%Y-%m-%d %H:%M"),
         create_date=None,
         size=long(filesize),
         owner=userid)
     _file_description.number_of_replicas = number_of_replicas
     _file_description.groupid = groupid
     _file_description.permissions = permissions
     return _file_description
Exemplo n.º 5
0
 def test_stat_dir(self):
     _stdout = (
         "Found 4 items\n"
         "drwxr-xr-x   - hbase hbase               0 2014-10-01 08:50 /hbase\n"
         "drwxrwxr-x   - solr  solr                0 2014-10-01 08:51 /solr\n"
         "drwxrwxrwt   - hdfs  supergroup          0 2014-10-03 14:13 /tmp\n"
         "drwxr-xr-x   - hdfs  supergroup          0 2014-10-01 09:11 /user"
     )
     with patch(HDFS_IS_DIR_FUNC) as mock_isdir:
         mock_isdir.return_value = True
         stat = hdfs_client.stat(
             "/user",
             executor=lambda cmd, *args: self._assert_command_generation(
                 os.path.join("hadoop fs -ls /user", ".."), stdout=_stdout)
             (cmd, *args))
         self.assertListEqual([
             "drwxr-xr-x", "-", "hdfs", "supergroup", "0", "2014-10-01",
             "09:11", "/user"
         ], stat)
Exemplo n.º 6
0
Arquivo: hdfs.py Projeto: epam/Merlin
 def get_description(self):
     """
     Gets metadata of file at the given path
     :return: FileDescriptor
     """
     permissions, number_of_replicas, userid, groupid, filesize, modification_date, modification_time, filename = tuple(
         fs.stat(self.path)
     )
     _file_description = FileDescriptor(
         name=self.path,
         update_date=datetime.strptime(" ".join([modification_date, modification_time[:5]]), "%Y-%m-%d %H:%M"),
         create_date=None,
         size=long(filesize),
         owner=userid,
     )
     _file_description.number_of_replicas = number_of_replicas
     _file_description.groupid = groupid
     _file_description.permissions = permissions
     return _file_description