开发者

How do you handle errors raised in Python Paramiko?

开发者 https://www.devze.com 2023-03-11 05:12 出处:网络
self.ssh = paramiko.SSHClient() self.ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) try: self.ssh.connect(self.hostname, username=self.username, password=self.password)
self.ssh = paramiko.SSHClient()
self.ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
try:
    self.ssh.connect(self.hostname, username=self.username, password=self.password)
except SSHException:
    #do something

I was wondering h开发者_开发百科ow to handle errors raised by Paramiko when trying to connect to an SSH server?


Depends on your application.

Here are some possible actions:

  • Terminate
  • Retry
  • Log the error and continue doing something else
0

精彩评论

暂无评论...
验证码 换一张
取 消