source: server/lib/gutenbach/ipp/core/errors.py @ 1037115

no-cups
Last change on this file since 1037115 was 1037115, checked in by Jessica B. Hamrick <jhamrick@…>, 12 years ago

Get rid of individual operations files -- too messy. Go back to having a single requests file for handling requests.

  • Property mode set to 100644
File size: 5.7 KB
Line 
1__all__ = [
2    'IPPException',
3    'IPPClientException',
4    'IPPServerException',
5
6    'ClientErrorBadRequest',
7    'ClientErrorForbidden',
8    'ClientErrorNotAuthenticated',
9    'ClientErrorNotAuthorized',
10    'ClientErrorNotPossible',
11    'ClientErrorTimeout',
12    'ClientErrorNotFound',
13    'ClientErrorGone',
14    'ClientErrorRequestEntity',
15    'ClientErrorRequestValue',
16    'ClientErrorDocumentFormatNotSupported',
17    'ClientErrorAttributes',
18    'ClientErrorUriSchemeNotSupported',
19    'ClientErrorCharsetNotSupported',
20    'ClientErrorConflict',
21    'ClientErrorCompressionNotSupported',
22    'ClientErrorCompressionError',
23    'ClientErrorDocumentFormatError',
24    'ClientErrorDocumentAccessError',
25    'ClientErrorAttributesNotSettable',
26    'ClientErrorIgnoredAllSubscriptions',
27    'ClientErrorTooManySubscriptions',
28    'ClientErrorIgnoredAllNotifications',
29    'ClientErrorPrintSupportFileNotFound',
30
31    'ServerErrorInternalError',
32    'ServerErrorOperationNotSupported',
33    'ServerErrorServiceUnavailable',
34    'ServerErrorVersionNotSupported',
35    'ServerErrorDeviceError',
36    'ServerErrorTemporaryError',
37    'ServerErrorNotAccepting',
38    'ServerErrorPrinterBusy',
39    'ServerErrorJobCancelled',
40    'ServerErrorMultipleJobsNotSupported',
41    'ServerErrorPrinterIsDeactivated',
42]
43   
44
45from .constants import ErrorCodes
46
47class IPPException(Exception):
48    def __init__(self, message=""):
49        self.message = message
50
51    def __str__(self):
52        return self.message
53
54class IPPClientException(IPPException):
55    def update_response(self, response):
56        if hasattr(self, "ipp_error_code"):
57            response.operation_id = self.ipp_error_code
58        else:
59            response.operation_id = ErrorCodes.BAD_REQUEST
60
61class IPPServerException(IPPException):
62    def update_response(self, response):
63        if hasattr(self, "ipp_error_code"):
64            response.operation_id = self.ipp_error_code
65        else:
66            response.operation_id = ErrorCodes.INTERNAL_ERROR
67   
68### Client error codes
69
70class ClientErrorBadRequest(IPPClientException):
71    ipp_error_code = ErrorCodes.BAD_REQUEST
72
73class ClientErrorForbidden(IPPClientException):
74    ipp_error_code = ErrorCodes.FORBIDDEN
75
76class ClientErrorNotAuthenticated(IPPClientException):
77    ipp_error_code = ErrorCodes.NOT_AUTHENTICATED
78
79class ClientErrorNotAuthorized(IPPClientException):
80    ipp_error_code = ErrorCodes.NOT_AUTHORIZED
81
82class ClientErrorNotPossible(IPPClientException):
83    ipp_error_code = ErrorCodes.NOT_POSSIBLE
84
85class ClientErrorTimeout(IPPClientException):
86    ipp_error_code = ErrorCodes.TIMEOUT
87
88class ClientErrorNotFound(IPPClientException):
89    ipp_error_code = ErrorCodes.NOT_FOUND
90
91class ClientErrorGone(IPPClientException):
92    ipp_error_code = ErrorCodes.GONE
93
94class ClientErrorRequestEntity(IPPClientException):
95    ipp_error_code = ErrorCodes.REQUEST_ENTITY
96
97class ClientErrorRequestValue(IPPClientException):
98    ipp_error_code = ErrorCodes.REQUEST_VALUE
99
100class ClientErrorDocumentFormatNotSupported(IPPClientException):
101    ipp_error_code = ErrorCodes.DOCUMENT_FORMAT
102
103class ClientErrorAttributes(IPPClientException):
104    ipp_error_code = ErrorCodes.ATTRIBUTES
105
106    def __init__(self, message, attrs):
107        self.message = message
108        self.bad_attrs = attrs
109
110    def update_response(self, response):
111        pass
112
113class ClientErrorUriSchemeNotSupported(IPPClientException):
114    ipp_error_code = ErrorCodes.URI_SCHEME
115
116class ClientErrorCharsetNotSupported(IPPClientException):
117    ipp_error_code = ErrorCodes.CHARSET
118
119class ClientErrorConflict(IPPClientException):
120    ipp_error_code = ErrorCodes.CONFLICT
121
122class ClientErrorCompressionNotSupported(IPPClientException):
123    ipp_error_code = ErrorCodes.COMPRESSION_NOT_SUPPORTED
124
125class ClientErrorCompressionError(IPPClientException):
126    ipp_error_code = ErrorCodes.COMPRESSION_ERROR
127
128class ClientErrorDocumentFormatError(IPPClientException):
129    ipp_error_code = ErrorCodes.DOCUMENT_FORMAT_ERROR
130
131class ClientErrorDocumentAccessError(IPPClientException):
132    ipp_error_code = ErrorCodes.DOCUMENT_ACCESS_ERROR
133
134class ClientErrorAttributesNotSettable(IPPClientException):
135    ipp_error_code = ErrorCodes.ATTRIBUTES_NOT_SETTABLE
136
137class ClientErrorIgnoredAllSubscriptions(IPPClientException):
138    ipp_error_code = ErrorCodes.IGNORED_ALL_SUBSCRIPTIONS
139
140class ClientErrorTooManySubscriptions(IPPClientException):
141    ipp_error_code = ErrorCodes.TOO_MANY_SUBSCRIPTIONS
142
143class ClientErrorIgnoredAllNotifications(IPPClientException):
144    ipp_error_code = ErrorCodes.IGNORED_ALL_NOTIFICATIONS
145
146class ClientErrorPrintSupportFileNotFound(IPPClientException):
147    ipp_error_code = ErrorCodes.PRINT_SUPPORT_FILE_NOT_FOUND
148
149### Server error codes
150
151class ServerErrorInternalError(IPPServerException):
152    ipp_error_code = ErrorCodes.INTERNAL_ERROR
153
154class ServerErrorOperationNotSupported(IPPServerException):
155    ipp_error_code = ErrorCodes.OPERATION_NOT_SUPPORTED
156
157class ServerErrorServiceUnavailable(IPPServerException):
158    ipp_error_code = ErrorCodes.SERVICE_UNAVAILABLE
159
160class ServerErrorVersionNotSupported(IPPServerException):
161    ipp_error_code = ErrorCodes.VERSION_NOT_SUPPORTED
162
163class ServerErrorDeviceError(IPPServerException):
164    ipp_error_code = ErrorCodes.DEVICE_ERROR
165
166class ServerErrorTemporaryError(IPPServerException):
167    ipp_error_code = ErrorCodes.TEMPORARY_ERROR
168
169class ServerErrorNotAccepting(IPPServerException):
170    ipp_error_code = ErrorCodes.NOT_ACCEPTING
171
172class ServerErrorPrinterBusy(IPPServerException):
173    ipp_error_code = ErrorCodes.PRINTER_BUSY
174
175class ServerErrorJobCancelled(IPPServerException):
176    ipp_error_code = ErrorCodes.ERROR_JOB_CANCELLED
177
178class ServerErrorMultipleJobsNotSupported(IPPServerException):
179    ipp_error_code = ErrorCodes.MULTIPLE_JOBS_NOT_SUPPORTED
180
181class ServerErrorPrinterIsDeactivated(IPPServerException):
182    ipp_error_code = ErrorCodes.PRINTER_IS_DEACTIVATED
Note: See TracBrowser for help on using the repository browser.