1from __future__ import unicode_literals
2
3
4class WinRMError(Exception):
5    """"Generic WinRM error"""
6    code = 500
7
8
9class WinRMTransportError(Exception):
10    """WinRM errors specific to transport-level problems (unexpcted HTTP error codes, etc)"""
11
12    @property
13    def protocol(self):
14        return self.args[0]
15
16    @property
17    def code(self):
18        return self.args[1]
19
20    @property
21    def message(self):
22        return 'Bad HTTP response returned from server. Code {0}'.format(self.code)
23
24    @property
25    def response_text(self):
26        return self.args[2]
27
28    def __str__(self):
29        return self.message
30
31
32class WinRMOperationTimeoutError(Exception):
33    """
34    Raised when a WinRM-level operation timeout (not a connection-level timeout) has occurred. This is
35    considered a normal error that should be retried transparently by the client when waiting for output from
36    a long-running process.
37    """
38    code = 500
39
40
41class AuthenticationError(WinRMError):
42    """Authorization Error"""
43    code = 401
44
45
46class BasicAuthDisabledError(AuthenticationError):
47    message = 'WinRM/HTTP Basic authentication is not enabled on remote host'
48
49
50class InvalidCredentialsError(AuthenticationError):
51    pass
52