- Timestamp:
- Dec 20, 2011, 1:47:11 PM (12 years ago)
- Branches:
- no-cups
- Children:
- 6effd50
- Parents:
- 5fe360e
- git-author:
- Jessica B. Hamrick <jhamrick@…> (12/20/11 13:47:11)
- git-committer:
- Jessica B. Hamrick <jhamrick@…> (12/20/11 13:47:11)
- Location:
- server/lib/gutenbach/ipp
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
server/lib/gutenbach/ipp/__init__.py
r71bfce0 rf6c6897 3 3 from request import Request 4 4 from value import Value 5 from constants import Tags 5 from constants import Tags, StatusCodes 6 6 import operations as ops 7 7 import exceptions as errors 8 8 9 __all__ = ['Attribute', 'AttributeGroup', 'Request', 'Value', 'Tags', 'ops', 'errors'] 9 __all__ = ['Attribute', 'AttributeGroup', 'Request', 'Value', 10 'Tags', 'StatusCodes', 'ops', 'errors'] -
server/lib/gutenbach/ipp/attribute.py
rd04a689 rf6c6897 66 66 for value in values: 67 67 assert isinstance(value, Value), \ 68 "Value % r must be of type Value" % (value)68 "Value %s must be of type Value" % (value,) 69 69 70 70 self.name = name … … 100 100 logger.debug("dumping name : %s" % self.name) 101 101 logger.debug("dumping value_length : %i" % value_length) 102 logger.debug("dumping value : %s" % v.value)102 logger.debug("dumping value (0x%x): %s" % (v.tag, v.value)) 103 103 104 104 # the value tag in binary 105 value_tag_bin = struct.pack('>b', v.value_tag)105 tag_bin = struct.pack('>b', v.tag) 106 106 107 107 # the name length in binary … … 115 115 116 116 if i == 0: 117 values.append(''.join([ value_tag_bin,117 values.append(''.join([tag_bin, 118 118 name_length_bin, 119 119 name_bin, … … 121 121 value_bin])) 122 122 else: 123 values.append(''.join([ value_tag_bin,123 values.append(''.join([tag_bin, 124 124 name_length_bin, 125 125 value_length_bin, -
server/lib/gutenbach/ipp/exceptions.py
r5b3a81e rf6c6897 25 25 26 26 class BadRequest(IPPClientException): 27 ipp_error_code = ErrorCodes.BAD_REQUEST )27 ipp_error_code = ErrorCodes.BAD_REQUEST 28 28 29 29 class Forbidden(IPPClientException): 30 ipp_error_code = ErrorCodes.FORBIDDEN )30 ipp_error_code = ErrorCodes.FORBIDDEN 31 31 32 32 class NotAuthenticated(IPPClientException): 33 ipp_error_code = ErrorCodes.NOT_AUTHENTICATED )33 ipp_error_code = ErrorCodes.NOT_AUTHENTICATED 34 34 35 35 class NotAuthorized(IPPClientException): 36 ipp_error_code = ErrorCodes.NOT_AUTHORIZED )36 ipp_error_code = ErrorCodes.NOT_AUTHORIZED 37 37 38 38 class NotPossible(IPPClientException): 39 ipp_error_code = ErrorCodes.NOT_POSSIBLE )39 ipp_error_code = ErrorCodes.NOT_POSSIBLE 40 40 41 41 class Timeout(IPPClientException): 42 ipp_error_code = ErrorCodes.TIMEOUT )42 ipp_error_code = ErrorCodes.TIMEOUT 43 43 44 44 class NotFound(IPPClientException): 45 ipp_error_code = ErrorCodes.NOT_FOUND )45 ipp_error_code = ErrorCodes.NOT_FOUND 46 46 47 47 class Gone(IPPClientException): 48 ipp_error_code = ErrorCodes.GONE )48 ipp_error_code = ErrorCodes.GONE 49 49 50 50 class RequestEntity(IPPClientException): 51 ipp_error_code = ErrorCodes.REQUEST_ENTITY )51 ipp_error_code = ErrorCodes.REQUEST_ENTITY 52 52 53 53 class RequestValue(IPPClientException): 54 ipp_error_code = ErrorCodes.REQUEST_VALUE )54 ipp_error_code = ErrorCodes.REQUEST_VALUE 55 55 56 56 class DocumentFormatNotSupported(IPPClientException): 57 ipp_error_code = ErrorCodes.DOCUMENT_FORMAT )57 ipp_error_code = ErrorCodes.DOCUMENT_FORMAT 58 58 59 59 class Attributes(IPPClientException): 60 ipp_error_code = ErrorCodes.ATTRIBUTES )60 ipp_error_code = ErrorCodes.ATTRIBUTES 61 61 62 62 def __init__(self, message, attrs): … … 68 68 69 69 class UriSchemeNotSupported(IPPClientException): 70 ipp_error_code = ErrorCodes.URI_SCHEME )70 ipp_error_code = ErrorCodes.URI_SCHEME 71 71 72 72 class CharsetNotSupported(IPPClientException): 73 ipp_error_code = ErrorCodes.CHARSET )73 ipp_error_code = ErrorCodes.CHARSET 74 74 75 75 class Conflict(IPPClientException): 76 ipp_error_code = ErrorCodes.CONFLICT )76 ipp_error_code = ErrorCodes.CONFLICT 77 77 78 78 class CompressionNotSupported(IPPClientException): 79 ipp_error_code = ErrorCodes.COMPRESSION_NOT_SUPPORTED )79 ipp_error_code = ErrorCodes.COMPRESSION_NOT_SUPPORTED 80 80 81 81 class CompressionError(IPPClientException): 82 ipp_error_code = ErrorCodes.COMPRESSION_ERROR )82 ipp_error_code = ErrorCodes.COMPRESSION_ERROR 83 83 84 84 class DocumentFormatError(IPPClientException): 85 ipp_error_code = ErrorCodes.DOCUMENT_FORMAT_ERROR )85 ipp_error_code = ErrorCodes.DOCUMENT_FORMAT_ERROR 86 86 87 87 class DocumentAccessError(IPPClientException): 88 ipp_error_code = ErrorCodes.DOCUMENT_ACCESS_ERROR )88 ipp_error_code = ErrorCodes.DOCUMENT_ACCESS_ERROR 89 89 90 90 class AttributesNotSettable(IPPClientException): 91 ipp_error_code = ErrorCodes.ATTRIBUTES_NOT_SETTABLE )91 ipp_error_code = ErrorCodes.ATTRIBUTES_NOT_SETTABLE 92 92 93 93 class IgnoredAllSubscriptions(IPPClientException): 94 ipp_error_code = ErrorCodes.IGNORED_ALL_SUBSCRIPTIONS )94 ipp_error_code = ErrorCodes.IGNORED_ALL_SUBSCRIPTIONS 95 95 96 96 class TooManySubscriptions(IPPClientException): 97 ipp_error_code = ErrorCodes.TOO_MANY_SUBSCRIPTIONS )97 ipp_error_code = ErrorCodes.TOO_MANY_SUBSCRIPTIONS 98 98 99 99 class IgnoredAllNotifications(IPPClientException): 100 ipp_error_code = ErrorCodes.IGNORED_ALL_NOTIFICATIONS )100 ipp_error_code = ErrorCodes.IGNORED_ALL_NOTIFICATIONS 101 101 102 102 class PrintSupportFileNotFound(IPPClientException): 103 ipp_error_code = ErrorCodes.PRINT_SUPPORT_FILE_NOT_FOUND )103 ipp_error_code = ErrorCodes.PRINT_SUPPORT_FILE_NOT_FOUND 104 104 105 105 ### Server error codes 106 106 107 107 class InternalError(IPPServerException): 108 ipp_error_code = ErrorCodes.INTERNAL_ERROR )108 ipp_error_code = ErrorCodes.INTERNAL_ERROR 109 109 110 110 class OperationNotSupported(IPPServerException): 111 ipp_error_code = ErrorCodes.OPERATION_NOT_SUPPORTED )111 ipp_error_code = ErrorCodes.OPERATION_NOT_SUPPORTED 112 112 113 113 class ServiceUnavailable(IPPServerException): 114 ipp_error_code = ErrorCodes.SERVICE_UNAVAILABLE )114 ipp_error_code = ErrorCodes.SERVICE_UNAVAILABLE 115 115 116 116 class VersionNotSupported(IPPServerException): 117 ipp_error_code = ErrorCodes.VERSION_NOT_SUPPORTED )117 ipp_error_code = ErrorCodes.VERSION_NOT_SUPPORTED 118 118 119 119 class DeviceError(IPPServerException): 120 ipp_error_code = ErrorCodes.DEVICE_ERROR )120 ipp_error_code = ErrorCodes.DEVICE_ERROR 121 121 122 122 class TemporaryError(IPPServerException): 123 ipp_error_code = ErrorCodes.TEMPORARY_ERROR )123 ipp_error_code = ErrorCodes.TEMPORARY_ERROR 124 124 125 125 class NotAccepting(IPPServerException): 126 ipp_error_code = ErrorCodes.NOT_ACCEPTING )126 ipp_error_code = ErrorCodes.NOT_ACCEPTING 127 127 128 128 class PrinterBusy(IPPServerException): 129 ipp_error_code = ErrorCodes.PRINTER_BUSY )129 ipp_error_code = ErrorCodes.PRINTER_BUSY 130 130 131 131 class ErrorJobCancelled(IPPServerException): 132 ipp_error_code = ErrorCodes.ERROR_JOB_CANCELLED )132 ipp_error_code = ErrorCodes.ERROR_JOB_CANCELLED 133 133 134 134 class MultipleJobsNotSupported(IPPServerException): 135 ipp_error_code = ErrorCodes.MULTIPLE_JOBS_NOT_SUPPORTED )135 ipp_error_code = ErrorCodes.MULTIPLE_JOBS_NOT_SUPPORTED 136 136 137 137 class PrinterIsDeactivated(IPPServerException): 138 ipp_error_code = ErrorCodes.PRINTER_IS_DEACTIVATED )138 ipp_error_code = ErrorCodes.PRINTER_IS_DEACTIVATED -
server/lib/gutenbach/ipp/operations.py
r71bfce0 rf6c6897 3 3 from .attributegroup import AttributeGroup 4 4 from .request import Request 5 from .constants import AttributeTags, operations_attribute_value_tags5 from .constants import AttributeTags, StatusCodes, operations_attribute_value_tags 6 6 import exceptions as err 7 8 from collections import OrderedDictionary as odict9 7 10 8 def verify_operations(request): … … 43 41 44 42 # check charset 45 charset attribute46 43 charset_attr = op_attrs.attributes[0] 47 44 if charset_attr.name != 'attributes-charset': … … 73 70 if natlang_value.tag != operations_attribute_value_tags['attributes-natural-language']: 74 71 raise err.BadRequest( 75 "Natural language value does not have NATURAL_LANGUAGE tag: 0x%x" natlang_value.tag)72 "Natural language value does not have NATURAL_LANGUAGE tag: 0x%x" % natlang_value.tag) 76 73 if natlang_value.value != 'en-us': 77 74 raise err.Attributes( … … 115 112 # Operation attributes -- typically the same for any request 116 113 attributes = [ 117 ipp.Attribute(114 Attribute( 118 115 'attributes-charset', 119 [ (operations_attribute_value_tags['attributes-charset'], 'utf-8')]),120 ipp.Attribute(116 [Value(operations_attribute_value_tags['attributes-charset'], 'utf-8')]), 117 Attribute( 121 118 'attributes-natural-language', 122 [ (operations_attribute_value_tags['attributes-natural-language'], 'en-us')])119 [Value(operations_attribute_value_tags['attributes-natural-language'], 'en-us')]) 123 120 ] 124 121 # Put the operation attributes in a group 125 attribute_group = ipp.AttributeGroup(126 const.AttributeTags.OPERATION,122 attribute_group = AttributeGroup( 123 AttributeTags.OPERATION, 127 124 attributes) 128 125 … … 131 128 response_kwargs = {} 132 129 response_kwargs['version'] = request.version 133 response_kwargs['operation_id'] = const.StatusCodes.OK130 response_kwargs['operation_id'] = StatusCodes.OK 134 131 response_kwargs['request_id'] = request.request_id 135 132 response_kwargs['attribute_groups'] = [attribute_group] 136 response = ipp.Request(**response_kwargs)133 response = Request(**response_kwargs) 137 134 138 135 return response … … 168 165 if 'which-jobs' or 'my-jobs' constrain which jobs are 169 166 returned. The limit is a 'stateless limit' in that if 170 the value supplied by the client is ’N’, then only the171 first ’N’jobs are returned in the Get-Jobs Response.172 There is no mechanism to allow for the next ’M’jobs173 after the first ’N’jobs. If the client does not167 the value supplied by the client is 'N', then only the 168 first 'N' jobs are returned in the Get-Jobs Response. 169 There is no mechanism to allow for the next 'M' jobs 170 after the first 'N' jobs. If the client does not 174 171 supply this attribute, the Printer object responds 175 172 with all applicable jobs. … … 185 182 the client does not supply this attribute, the Printer 186 183 MUST respond as if the client had supplied this 187 attribute with two values: ’job-uri’ and ’job-id’.184 attribute with two values: 'job-uri' and 'job-id'. 188 185 'which-jobs' (type2 keyword): 189 186 The client OPTIONALLY supplies this attribute. The … … 191 188 indicates which Job objects MUST be returned by the 192 189 Printer object. The values for this attribute are: 193 - ’completed’: This includes any Job object whose194 state is ’completed’, ’canceled’, or ’aborted’.195 - ’not-completed’: This includes any Job object whose196 state is ’pending’, ’processing’,197 ’processing-stopped’, or ’pending-held’.190 - 'completed': This includes any Job object whose 191 state is 'completed', 'canceled', or 'aborted'. 192 - 'not-completed': This includes any Job object whose 193 state is 'pending', 'processing', 194 'processing-stopped', or 'pending-held'. 198 195 A Printer object MUST support both values. However, if 199 196 the implementation does not keep jobs in the 200 ’completed’, ’canceled’, and ’aborted’states, then it201 returns no jobs when the ’completed’value is197 'completed', 'canceled', and 'aborted' states, then it 198 returns no jobs when the 'completed' value is 202 199 supplied. If a client supplies some other value, the 203 200 Printer object MUST copy the attribute and the 204 201 unsupported value to the Unsupported Attributes 205 202 response group, reject the request, and return the 206 ’client-error-attributes-or-values-not-supported’203 'client-error-attributes-or-values-not-supported' 207 204 status code. If the client does not supply this 208 205 attribute, the Printer object MUST respond as if the 209 206 client had supplied the attribute with a value of 210 ’not-completed’.207 'not-completed'. 211 208 'my-jobs' (boolean): 212 209 The client OPTIONALLY supplies this attribute. The … … 218 215 attribute, the Printer object MUST respond as if the 219 216 client had supplied the attribute with a value of 220 ’false’, i.e., jobs from all users. The means for217 'false', i.e., jobs from all users. The means for 221 218 authenticating the requesting user and matching the 222 219 jobs is described in section 8. … … 268 265 response returns 0 jobs because there are no jobs matching the 269 266 criteria, and the request would have returned 1 or more jobs 270 with a status code of ’successful-ok’if there had been jobs267 with a status code of 'successful-ok' if there had been jobs 271 268 matching the criteria, then the status code for 0 jobs MUST be 272 ’successful-ok’.269 'successful-ok'. 273 270 274 271 Group 1: Operation Attributes … … 293 290 referenced in the 'requested-attributes' operation 294 291 attribute and that attribute included group names, such as 295 ’all’, the unsupported attributes MUST NOT include292 'all', the unsupported attributes MUST NOT include 296 293 attributes described in the standard but not supported by 297 294 the implementation. … … 306 303 job (job originating user) or not (see section 307 304 8). However, the Printer object MUST respond with the 308 ’unknown’value for any supported attribute (including all305 'unknown' value for any supported attribute (including all 309 306 REQUIRED attributes) for which the Printer object does not 310 307 know the value, unless it would violate the security … … 313 310 314 311 Jobs are returned in the following order: 315 - If the client requests all ’completed’Jobs (Jobs in the316 ’completed’, ’aborted’, or ’canceled’states), then the312 - If the client requests all 'completed' Jobs (Jobs in the 313 'completed', 'aborted', or 'canceled' states), then the 317 314 Jobs are returned newest to oldest (with respect to 318 315 actual completion time) 319 - If the client requests all ’not-completed’Jobs (Jobs in320 the ’pending’, ’processing’, ’pending-held’, and321 ’processing- stopped’states), then Jobs are returned in316 - If the client requests all 'not-completed' Jobs (Jobs in 317 the 'pending', 'processing', 'pending-held', and 318 'processing- stopped' states), then Jobs are returned in 322 319 relative chronological order of expected time to 323 320 complete (based on whatever scheduling algorithm is
Note: See TracChangeset
for help on using the changeset viewer.