cmdshell.py 文件源码

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

项目:depot_tools 作者: webrtc-uwp 项目源码 文件源码
def connect(self, num_retries=5):
        retry = 0
        while retry < num_retries:
            try:
                self._ssh_client.connect(self.server.hostname,
                                         username=self.uname,
                                         pkey=self._pkey)
                return
            except socket.error, (value, message):
                if value in (51, 61, 111):
                    print 'SSH Connection refused, will retry in 5 seconds'
                    time.sleep(5)
                    retry += 1
                else:
                    raise
            except paramiko.BadHostKeyException:
                print "%s has an entry in ~/.ssh/known_hosts and it doesn't match" % self.server.hostname
                print 'Edit that file to remove the entry and then hit return to try again'
                raw_input('Hit Enter when ready')
                retry += 1
            except EOFError:
                print 'Unexpected Error from SSH Connection, retry in 5 seconds'
                time.sleep(5)
                retry += 1
        print 'Could not establish SSH connection'
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号