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
RevLine 
[1037115]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
[7de0908]45from .constants import ErrorCodes
46
47class IPPException(Exception):
[aded2d1]48    def __init__(self, message=""):
[7de0908]49        self.message = message
50
51    def __str__(self):
52        return self.message
53
[5b3a81e]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
[7de0908]67   
[5b3a81e]68### Client error codes
69
[aded2d1]70class ClientErrorBadRequest(IPPClientException):
[f6c6897]71    ipp_error_code = ErrorCodes.BAD_REQUEST
[7de0908]72
[aded2d1]73class ClientErrorForbidden(IPPClientException):
[f6c6897]74    ipp_error_code = ErrorCodes.FORBIDDEN
[7de0908]75
[aded2d1]76class ClientErrorNotAuthenticated(IPPClientException):
[f6c6897]77    ipp_error_code = ErrorCodes.NOT_AUTHENTICATED
[7de0908]78
[aded2d1]79class ClientErrorNotAuthorized(IPPClientException):
[f6c6897]80    ipp_error_code = ErrorCodes.NOT_AUTHORIZED
[7de0908]81
[aded2d1]82class ClientErrorNotPossible(IPPClientException):
[f6c6897]83    ipp_error_code = ErrorCodes.NOT_POSSIBLE
[7de0908]84
[aded2d1]85class ClientErrorTimeout(IPPClientException):
[f6c6897]86    ipp_error_code = ErrorCodes.TIMEOUT
[7de0908]87
[aded2d1]88class ClientErrorNotFound(IPPClientException):
[f6c6897]89    ipp_error_code = ErrorCodes.NOT_FOUND
[7de0908]90
[aded2d1]91class ClientErrorGone(IPPClientException):
[f6c6897]92    ipp_error_code = ErrorCodes.GONE
[7de0908]93
[aded2d1]94class ClientErrorRequestEntity(IPPClientException):
[f6c6897]95    ipp_error_code = ErrorCodes.REQUEST_ENTITY
[7de0908]96
[aded2d1]97class ClientErrorRequestValue(IPPClientException):
[f6c6897]98    ipp_error_code = ErrorCodes.REQUEST_VALUE
[7de0908]99
[aded2d1]100class ClientErrorDocumentFormatNotSupported(IPPClientException):
[f6c6897]101    ipp_error_code = ErrorCodes.DOCUMENT_FORMAT
[7de0908]102
[aded2d1]103class ClientErrorAttributes(IPPClientException):
[f6c6897]104    ipp_error_code = ErrorCodes.ATTRIBUTES
[7de0908]105
106    def __init__(self, message, attrs):
107        self.message = message
108        self.bad_attrs = attrs
109
[5b3a81e]110    def update_response(self, response):
111        pass
[7de0908]112
[aded2d1]113class ClientErrorUriSchemeNotSupported(IPPClientException):
[f6c6897]114    ipp_error_code = ErrorCodes.URI_SCHEME
[7de0908]115
[aded2d1]116class ClientErrorCharsetNotSupported(IPPClientException):
[f6c6897]117    ipp_error_code = ErrorCodes.CHARSET
[7de0908]118
[aded2d1]119class ClientErrorConflict(IPPClientException):
[f6c6897]120    ipp_error_code = ErrorCodes.CONFLICT
[7de0908]121
[aded2d1]122class ClientErrorCompressionNotSupported(IPPClientException):
[f6c6897]123    ipp_error_code = ErrorCodes.COMPRESSION_NOT_SUPPORTED
[7de0908]124
[aded2d1]125class ClientErrorCompressionError(IPPClientException):
[f6c6897]126    ipp_error_code = ErrorCodes.COMPRESSION_ERROR
[7de0908]127
[aded2d1]128class ClientErrorDocumentFormatError(IPPClientException):
[f6c6897]129    ipp_error_code = ErrorCodes.DOCUMENT_FORMAT_ERROR
[7de0908]130
[aded2d1]131class ClientErrorDocumentAccessError(IPPClientException):
[f6c6897]132    ipp_error_code = ErrorCodes.DOCUMENT_ACCESS_ERROR
[7de0908]133
[aded2d1]134class ClientErrorAttributesNotSettable(IPPClientException):
[f6c6897]135    ipp_error_code = ErrorCodes.ATTRIBUTES_NOT_SETTABLE
[7de0908]136
[aded2d1]137class ClientErrorIgnoredAllSubscriptions(IPPClientException):
[f6c6897]138    ipp_error_code = ErrorCodes.IGNORED_ALL_SUBSCRIPTIONS
[7de0908]139
[aded2d1]140class ClientErrorTooManySubscriptions(IPPClientException):
[f6c6897]141    ipp_error_code = ErrorCodes.TOO_MANY_SUBSCRIPTIONS
[7de0908]142
[aded2d1]143class ClientErrorIgnoredAllNotifications(IPPClientException):
[f6c6897]144    ipp_error_code = ErrorCodes.IGNORED_ALL_NOTIFICATIONS
[7de0908]145
[aded2d1]146class ClientErrorPrintSupportFileNotFound(IPPClientException):
[f6c6897]147    ipp_error_code = ErrorCodes.PRINT_SUPPORT_FILE_NOT_FOUND
[7de0908]148
149### Server error codes
150
[aded2d1]151class ServerErrorInternalError(IPPServerException):
[f6c6897]152    ipp_error_code = ErrorCodes.INTERNAL_ERROR
[7de0908]153
[aded2d1]154class ServerErrorOperationNotSupported(IPPServerException):
[f6c6897]155    ipp_error_code = ErrorCodes.OPERATION_NOT_SUPPORTED
[7de0908]156
[aded2d1]157class ServerErrorServiceUnavailable(IPPServerException):
[f6c6897]158    ipp_error_code = ErrorCodes.SERVICE_UNAVAILABLE
[7de0908]159
[aded2d1]160class ServerErrorVersionNotSupported(IPPServerException):
[f6c6897]161    ipp_error_code = ErrorCodes.VERSION_NOT_SUPPORTED
[7de0908]162
[aded2d1]163class ServerErrorDeviceError(IPPServerException):
[f6c6897]164    ipp_error_code = ErrorCodes.DEVICE_ERROR
[7de0908]165
[aded2d1]166class ServerErrorTemporaryError(IPPServerException):
[f6c6897]167    ipp_error_code = ErrorCodes.TEMPORARY_ERROR
[7de0908]168
[aded2d1]169class ServerErrorNotAccepting(IPPServerException):
[f6c6897]170    ipp_error_code = ErrorCodes.NOT_ACCEPTING
[7de0908]171
[aded2d1]172class ServerErrorPrinterBusy(IPPServerException):
[f6c6897]173    ipp_error_code = ErrorCodes.PRINTER_BUSY
[7de0908]174
[1037115]175class ServerErrorJobCancelled(IPPServerException):
[f6c6897]176    ipp_error_code = ErrorCodes.ERROR_JOB_CANCELLED
[7de0908]177
[aded2d1]178class ServerErrorMultipleJobsNotSupported(IPPServerException):
[f6c6897]179    ipp_error_code = ErrorCodes.MULTIPLE_JOBS_NOT_SUPPORTED
[7de0908]180
[aded2d1]181class ServerErrorPrinterIsDeactivated(IPPServerException):
[f6c6897]182    ipp_error_code = ErrorCodes.PRINTER_IS_DEACTIVATED
Note: See TracBrowser for help on using the repository browser.