Beispiel #1
0
    def _path_stat(self, fn):
        try:
            st = self.sftp.stat(str(fn))
        except IOError as e:
            if e.errno == errno.ENOENT:
                return None
            raise OSError(e.errno)
        res = StatRes((
            st.st_mode,
            0,
            0,
            0,
            st.st_uid,
            st.st_gid,
            st.st_size,
            st.st_atime,
            st.st_mtime,
            0,
        ))

        if stat.S_ISDIR(st.st_mode):
            res.text_mode = "directory"
        if stat.S_ISREG(st.st_mode):
            res.text_mode = "regular file"
        return res
Beispiel #2
0
 def _path_stat(self, fn):
     rc, out, _ = self._session.run("stat -c '%F,%f,%i,%d,%h,%u,%g,%s,%X,%Y,%Z' " + shquote(fn), retcode=None)
     if rc != 0:
         return None
     statres = out.strip().split(",")
     text_mode = statres.pop(0).lower()
     res = StatRes((int(statres[0], 16),) + tuple(int(sr) for sr in statres[1:]))
     res.text_mode = text_mode
     return res
Beispiel #3
0
 def _path_stat(self, fn):
     rc, out, _ = self._session.run("stat -c '%F,%f,%i,%d,%h,%u,%g,%s,%X,%Y,%Z' " + shquote(fn),
         retcode = None)
     if rc != 0:
         return None
     statres = out.strip().split(",")
     text_mode = statres.pop(0).lower()
     res = StatRes((int(statres[0], 16),) + tuple(int(sr) for sr in statres[1:]))
     res.text_mode = text_mode
     return res
Beispiel #4
0
 def _path_stat(self, fn):
     if self.uname not in ('Darwin', 'FreeBSD'):
         stat_cmd = "stat -c '%F,%f,%i,%d,%h,%u,%g,%s,%X,%Y,%Z' "
     else:
         stat_cmd = "stat -f '%HT,%Xp,%i,%d,%l,%u,%g,%z,%a,%m,%c' "
     rc, out, _ = self._session.run(stat_cmd + shquote(fn), retcode = None)
     if rc != 0:
         return None
     statres = out.strip().split(",")
     text_mode = statres.pop(0).lower()
     res = StatRes((int(statres[0], 16),) + tuple(int(sr) for sr in statres[1:]))
     res.text_mode = text_mode
     return res
    def _path_stat(self, fn):
        try:
            st = self.sftp.stat(str(fn))
        except IOError as e:
            if e.errno == errno.ENOENT:
                return None
            raise OSError(e.errno)
        res = StatRes((st.st_mode, 0, 0, 0, st.st_uid, st.st_gid,
                       st.st_size, st.st_atime, st.st_mtime, 0))

        if stat.S_ISDIR(st.st_mode):
            res.text_mode = 'directory'
        if stat.S_ISREG(st.st_mode):
            res.text_mode = 'regular file'
        return res