vm.py 文件源码

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

项目:vcdriver 作者: Lantero 项目源码 文件源码
def ssh_download(
            self,
            remote_path,
            local_path,
            use_sudo=False,
            quiet=False,
            **kwargs
    ):
        """
        Download a file or directory from the virtual machine
        :param remote_path: The remote location
        :param local_path: The local local
        :param use_sudo: If True, it runs as sudo
        :param quiet: Whether to hide the stdout/stderr output or not

        :return: The list of downloaded files

        :raise: DownloadError: If the task fails
        """
        if self._vm_object:
            self._wait_for_ssh_service(
                kwargs['vcdriver_vm_ssh_username'],
                kwargs['vcdriver_vm_ssh_password']
            )
            with fabric_context(
                    self.ip(),
                    kwargs['vcdriver_vm_ssh_username'],
                    kwargs['vcdriver_vm_ssh_password']
            ):
                if quiet:
                    with hide('everything'):
                        result = get(
                            remote_path, local_path, use_sudo=use_sudo
                        )
                else:
                    result = get(remote_path, local_path, use_sudo=use_sudo)
                if result.failed:
                    raise DownloadError(
                        local_path=local_path,
                        remote_path=remote_path
                    )
                else:
                    return result
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号