示例#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
示例#2
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
示例#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
示例#4
0
文件: remote.py 项目: fruch/plumbum
 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
示例#5
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