sshutils.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:niceman 作者: ReproNim 项目源码 文件源码
def get(self, remotepaths, localpath=''):
        """
        Copies one or more files from the remote host to the local host.
        """
        remotepaths = self._make_list(remotepaths)
        localpath = localpath or os.getcwd()
        globs = []
        noglobs = []
        for rpath in remotepaths:
            if glob.has_magic(rpath):
                globs.append(rpath)
            else:
                noglobs.append(rpath)
        globresults = [self.glob(g) for g in globs]
        remotepaths = noglobs
        for globresult in globresults:
            remotepaths.extend(globresult)
        recursive = False
        for rpath in remotepaths:
            if not self.path_exists(rpath):
                raise exception.BaseException(
                    "Remote file or directory does not exist: %s" % rpath)
        for rpath in remotepaths:
            if self.isdir(rpath):
                recursive = True
                break
        try:
            self.scp.get(remotepaths, local_path=localpath,
                         recursive=recursive)
        except Exception as e:
            log.debug("get failed: remotepaths=%s, localpath=%s",
                      str(remotepaths), localpath)
            raise exception.SCPException(str(e))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号