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