Package paramiko :: Module ssh_exception
[frames] | no frames]

Source Code for Module paramiko.ssh_exception

  1  # Copyright (C) 2003-2007  Robey Pointer <robeypointer@gmail.com> 
  2  # 
  3  # This file is part of paramiko. 
  4  # 
  5  # Paramiko is free software; you can redistribute it and/or modify it under the 
  6  # terms of the GNU Lesser General Public License as published by the Free 
  7  # Software Foundation; either version 2.1 of the License, or (at your option) 
  8  # any later version. 
  9  # 
 10  # Paramiko is distributed in the hope that it will be useful, but WITHOUT ANY 
 11  # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR 
 12  # A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more 
 13  # details. 
 14  # 
 15  # You should have received a copy of the GNU Lesser General Public License 
 16  # along with Paramiko; if not, write to the Free Software Foundation, Inc., 
 17  # 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA. 
 18   
 19   
20 -class SSHException (Exception):
21 """ 22 Exception raised by failures in SSH2 protocol negotiation or logic errors. 23 """ 24 pass
25 26
27 -class AuthenticationException (SSHException):
28 """ 29 Exception raised when authentication failed for some reason. It may be 30 possible to retry with different credentials. (Other classes specify more 31 specific reasons.) 32 33 .. versionadded:: 1.6 34 """ 35 pass
36 37
38 -class PasswordRequiredException (AuthenticationException):
39 """ 40 Exception raised when a password is needed to unlock a private key file. 41 """ 42 pass
43 44
45 -class BadAuthenticationType (AuthenticationException):
46 """ 47 Exception raised when an authentication type (like password) is used, but 48 the server isn't allowing that type. (It may only allow public-key, for 49 example.) 50 51 :ivar list allowed_types: 52 list of allowed authentication types provided by the server (possible 53 values are: ``"none"``, ``"password"``, and ``"publickey"``). 54 55 .. versionadded:: 1.1 56 """ 57 allowed_types = [] 58
59 - def __init__(self, explanation, types):
60 AuthenticationException.__init__(self, explanation) 61 self.allowed_types = types 62 # for unpickling 63 self.args = (explanation, types, )
64
65 - def __str__(self):
66 return SSHException.__str__(self) + ' (allowed_types=%r)' % self.allowed_types
67 68
69 -class PartialAuthentication (AuthenticationException):
70 """ 71 An internal exception thrown in the case of partial authentication. 72 """ 73 allowed_types = [] 74
75 - def __init__(self, types):
76 AuthenticationException.__init__(self, 'partial authentication') 77 self.allowed_types = types 78 # for unpickling 79 self.args = (types, )
80 81
82 -class ChannelException (SSHException):
83 """ 84 Exception raised when an attempt to open a new `.Channel` fails. 85 86 :ivar int code: the error code returned by the server 87 88 .. versionadded:: 1.6 89 """
90 - def __init__(self, code, text):
91 SSHException.__init__(self, text) 92 self.code = code 93 # for unpickling 94 self.args = (code, text, )
95 96
97 -class BadHostKeyException (SSHException):
98 """ 99 The host key given by the SSH server did not match what we were expecting. 100 101 :ivar str hostname: the hostname of the SSH server 102 :ivar PKey got_key: the host key presented by the server 103 :ivar PKey expected_key: the host key expected 104 105 .. versionadded:: 1.6 106 """
107 - def __init__(self, hostname, got_key, expected_key):
108 SSHException.__init__(self, 'Host key for server %s does not match!' % hostname) 109 self.hostname = hostname 110 self.key = got_key 111 self.expected_key = expected_key 112 # for unpickling 113 self.args = (hostname, got_key, expected_key, )
114 115
116 -class ProxyCommandFailure (SSHException):
117 """ 118 The "ProxyCommand" found in the .ssh/config file returned an error. 119 120 :ivar str command: The command line that is generating this exception. 121 :ivar str error: The error captured from the proxy command output. 122 """
123 - def __init__(self, command, error):
124 SSHException.__init__(self, 125 '"ProxyCommand (%s)" returned non-zero exit status: %s' % ( 126 command, error 127 ) 128 ) 129 self.error = error 130 # for unpickling 131 self.args = (command, error, )
132