Changeset 793432f for server/lib/gutenbach/ipp
- Timestamp:
- Dec 23, 2011, 9:37:39 PM (12 years ago)
- Branches:
- no-cups
- Children:
- 1037115
- Parents:
- b828a96
- git-author:
- Jessica B. Hamrick <jhamrick@…> (12/23/11 21:37:39)
- git-committer:
- Jessica B. Hamrick <jhamrick@…> (12/23/11 21:37:39)
- Location:
- server/lib/gutenbach/ipp
- Files:
-
- 2 added
- 2 deleted
- 2 edited
- 9 moved
Legend:
- Unmodified
- Added
- Removed
-
server/lib/gutenbach/ipp/__init__.py
rb828a96 r793432f 1 __all__ = [] 1 import core 2 from core import * 3 __all__ = ['core'] 4 __all__.extend(core.__all__) 5 print __all__ 2 6 3 from attribute import Attribute 4 __all__.append('Attribute') 5 6 from attributegroup import AttributeGroup 7 __all__.append('AttributeGroup') 8 9 from request import Request 10 __all__.append('Request') 11 12 from value import Value 13 __all__.append('Value') 14 15 import constants 16 from constants import * 17 __all__.append('constants') 18 __all__.extend(constants.__all__) 19 20 import errors 21 __all__.append('errors') 22 23 import object_attributes 24 from object_attributes import * 25 __all__.append('object_attributes') 26 __all__.extend(object_attributes.__all__) 7 import attributes 8 from attributes import * 9 __all__.append('attributes') 10 __all__.extend(attributes.__all__) 27 11 28 12 # this import needs to come last 29 import operations as ops 30 __all__.append('ops') 13 import operations 14 from operations import * 15 __all__.append('operations') 16 __all__.extend(operations.__all__) -
server/lib/gutenbach/ipp/attributes/job.py
rb828a96 r793432f 1 1 __all__ = [ 2 'JobPriority', 3 'JobHoldUntil', 4 'JobSheets', 5 'MultipleDocumentHandling', 6 'Copies', 7 'Finishings', 8 'PageRanges', 9 'Sides', 10 'NumberUp', 11 'OrientationRequested', 12 'Media', 13 'PrinterResolution', 14 'PrintQuality', 15 2 16 'JobUri', 3 17 'JobId', … … 32 46 ] 33 47 34 from ..attribute import Attribute 35 from ..value import Value 36 from ..exceptions import ClientErrorAttributes 37 from ..constants import * 48 from .. import Attribute 49 from .. import Value 50 from .. import errors 51 from .. import IntegerTags, CharacterStringTags 52 53 def JobPriority(val): 54 """4.2.1 job-priority (integer(1:100)) 55 56 This attribute specifies a priority for scheduling the Job. A 57 higher value specifies a higher priority. The value 1 indicates 58 the lowest possible priority. The value 100 indicates the highest 59 possible priority. Among those jobs that are ready to print, a 60 Printer MUST print all jobs with a priority value of n before 61 printing those with a priority value of n-1 for all n. 62 63 If the Printer object supports this attribute, it MUST always 64 support the full range from 1 to 100. No administrative 65 restrictions are permitted. This way an end-user can always make 66 full use of the entire range with any Printer object. If 67 privileged jobs are implemented outside IPP/1.1, they MUST have 68 priorities higher than 100, rather than restricting the range 69 available to end-users. 70 71 If the client does not supply this attribute and this attribute is 72 supported by the Printer object, the Printer object MUST use the 73 value of the Printer object's 'job-priority-default' at job 74 submission time (unlike most Job Template attributes that are used 75 if necessary at job processing time). 76 77 The syntax for the 'job-priority-supported' is also 78 integer(1:100). This single integer value indicates the number of 79 priority levels supported. The Printer object MUST take the value 80 supplied by the client and map it to the closest integer in a 81 sequence of n integers values that are evenly distributed over the 82 range from 1 to 100 using the formula: 83 84 roundToNearestInt((100x+50)/n) 85 86 where n is the value of 'job-priority-supported' and x ranges from 87 0 through n-1. 88 89 For example, if n=1 the sequence of values is 50; if n=2, the 90 sequence of values is: 25 and 75; if n = 3, the sequence of values 91 is: 17, 50 and 83; if n = 10, the sequence of values is: 5, 15, 92 25, 35, 45, 55, 65, 75, 85, and 95; if n = 100, the sequence of 93 values is: 1, 2, 3, ... 100. 94 95 If the value of the Printer object's 'job-priority-supported' is 96 10 and the client supplies values in the range 1 to 10, the 97 Printer object maps them to 5, in the range 11 to 20, the Printer 98 object maps them to 15, etc. 99 100 """ 101 102 103 return Attribute( 104 'job-priority', 105 [Value(IntegerTags.INTEGER), val]) 106 107 def JobHoldUntil(val): 108 """4.2.2 job-hold-until (type3 keyword | name (MAX)) 109 110 """ 111 112 raise errors.ClientErrorAttributes, "job-hold-until" 113 114 def JobSheets(val): 115 """4.2.3 job-sheets (type3 keyword | name(MAX)) 116 117 """ 118 119 raise errors.ClientErrorAttributes, "job-sheets" 120 121 def MultipleDocumentHandling(val): 122 """4.2.4 multiple-document-handling (type2 keyword) 123 124 """ 125 126 raise errors.ClientErrorAttributes, "multiple-document-handling" 127 128 def Copies(val): 129 """4.2.5 copies (integer(1:MAX)) 130 131 """ 132 133 raise errors.ClientErrorAttributes, "copies" 134 135 def Finishings(*vals): 136 """4.2.6 finishings (1setOf type2 enum) 137 138 """ 139 140 raise errors.ClientErrorAttributes, "finishings" 141 142 def PageRanges(*vals): 143 """4.2.7 page-ranges (1setOf rangeOfInteger (1:MAX)) 144 145 """ 146 147 raise errors.ClientErrorAttributes, "page-ranges" 148 149 def Sides(val): 150 """4.2.8 sides (type2 keyword) 151 152 """ 153 154 raise errors.ClientErrorAttributes, "sides" 155 156 def NumberUp(val): 157 """4.2.9 number-up (integer(1:MAX)) 158 159 """ 160 161 raise errors.ClientErrorAttributes, "number-up" 162 163 def OrientationRequested(val): 164 """4.2.10 orientation-requested (type2 enum) 165 166 """ 167 168 raise errors.ClientErrorAttributes, "orientation-requested" 169 170 def Media(val): 171 """4.2.11 media (type3 keyword | name(MAX)) 172 173 """ 174 175 raise errors.ClientErrorAttributes, "media" 176 177 ### XXX: we may want to repurpose this for bitrate? 178 def PrinterResolution(val): 179 """4.2.12 printer-resolution (resolution) 180 181 """ 182 183 raise errors.ClientErrorAttributes, "printer-resolution" 184 185 def PrintQuality(val): 186 """4.2.13 print-quality (type2 enum) 187 188 """ 189 190 raise errors.ClientErrorAttributes, "print-quality" 38 191 39 192 def JobUri(val): … … 112 265 """ 113 266 114 raise ClientErrorAttributes, "job-more-info"267 raise errors.ClientErrorAttributes, "job-more-info" 115 268 116 269 def JobName(val): … … 214 367 """ 215 368 216 raise ClientErrorAttributes, "job-state-message"369 raise errors.ClientErrorAttributes, "job-state-message" 217 370 218 371 def JobDetailedStatusMessages(val): … … 221 374 """ 222 375 223 raise ClientErrorAttributes, "job-detailed-status-messages"376 raise errors.ClientErrorAttributes, "job-detailed-status-messages" 224 377 225 378 def JobDocumentAccessErrors(val): … … 228 381 """ 229 382 230 raise ClientErrorAttributes, "job-document-access-errors"383 raise errors.ClientErrorAttributes, "job-document-access-errors" 231 384 232 385 def NumberOfDocuments(val): … … 235 388 """ 236 389 237 raise ClientErrorAttributes, "number-of-documents"390 raise errors.ClientErrorAttributes, "number-of-documents" 238 391 239 392 def OutputDeviceAssigned(val): … … 242 395 """ 243 396 244 raise ClientErrorAttributes, "output-device-assigned"397 raise errors.ClientErrorAttributes, "output-device-assigned" 245 398 246 399 def TimeAtCreation(val): … … 315 468 """ 316 469 317 raise ClientErrorAttributes, "date-time-at-creation"470 raise errors.ClientErrorAttributes, "date-time-at-creation" 318 471 319 472 def DateTimeAtProcessing(val): … … 322 475 """ 323 476 324 raise ClientErrorAttributes, "date-time-at-processing"477 raise errors.ClientErrorAttributes, "date-time-at-processing" 325 478 326 479 def DateTimeAtCompletion(val): … … 329 482 """ 330 483 331 raise ClientErrorAttributes, "date-time-at-completion"484 raise errors.ClientErrorAttributes, "date-time-at-completion" 332 485 333 486 def NumberOfInterveningJobs(val): … … 336 489 """ 337 490 338 raise ClientErrorAttributes, "number-of-intervening-jobs"491 raise errors.ClientErrorAttributes, "number-of-intervening-jobs" 339 492 340 493 def JobMessageFromOperator(val): … … 343 496 """ 344 497 345 raise ClientErrorAttributes, "job-message-from-operator"498 raise errors.ClientErrorAttributes, "job-message-from-operator" 346 499 347 500 def JobKOctets(val): … … 379 532 """ 380 533 381 raise ClientErrorAttributes, "job-impressions"534 raise errors.ClientErrorAttributes, "job-impressions" 382 535 383 536 def JobMediaSheets(val): … … 386 539 """ 387 540 388 raise ClientErrorAttributes, "job-media-sheets"541 raise errors.ClientErrorAttributes, "job-media-sheets" 389 542 390 543 def JobKOctetsProcessed(val): … … 393 546 """ 394 547 395 raise ClientErrorAttributes, "job-k-octets-processed"548 raise errors.ClientErrorAttributes, "job-k-octets-processed" 396 549 397 550 def JobImpressionsCompleted(val): … … 400 553 """ 401 554 402 raise ClientErrorAttributes, "job-impressions-completed"555 raise errors.ClientErrorAttributes, "job-impressions-completed" 403 556 404 557 def JobMediaSheetsCompleted(val): … … 407 560 """ 408 561 409 raise ClientErrorAttributes, "job-media-sheets-completed"562 raise errors.ClientErrorAttributes, "job-media-sheets-completed" 410 563 411 564 def AttributesCharset(val): -
server/lib/gutenbach/ipp/attributes/operation.py
rb828a96 r793432f 4 4 ] 5 5 6 from .. attributeimport Attribute7 from .. valueimport Value8 from .. exceptions import ClientErrorAttributes9 from .. constants import *6 from .. import Attribute 7 from .. import Value 8 from .. import errors 9 from .. import CharacterStringTags 10 10 11 11 def PrinterUri(val): -
server/lib/gutenbach/ipp/attributes/printer.py
rb828a96 r793432f 39 39 ] 40 40 41 from .. attributeimport Attribute42 from .. valueimport Value43 from .. exceptions import ClientErrorAttributes44 from .. constants import *41 from .. import Attribute 42 from .. import Value 43 from .. import errors 44 from .. import IntegerTags, CharacterStringTags 45 45 46 46 def PrinterUriSupported(*vals): … … 140 140 """ 141 141 142 raise ClientErrorAttributes, "printer-location"142 raise errors.ClientErrorAttributes, "printer-location" 143 143 144 144 def PrinterInfo(val): … … 147 147 """ 148 148 149 raise ClientErrorAttributes, "printer-info"149 raise errors.ClientErrorAttributes, "printer-info" 150 150 151 151 def PrinterMoreInfo(val): … … 154 154 """ 155 155 156 raise ClientErrorAttributes, "printer-more-info"156 raise errors.ClientErrorAttributes, "printer-more-info" 157 157 158 158 def PrinterDriverInstaller(val): … … 161 161 """ 162 162 163 raise ClientErrorAttributes, "printer-driver-installer"163 raise errors.ClientErrorAttributes, "printer-driver-installer" 164 164 165 165 def PrinterMakeAndModel(val): … … 168 168 """ 169 169 170 raise ClientErrorAttributes, "printer-make-and-model"170 raise errors.ClientErrorAttributes, "printer-make-and-model" 171 171 172 172 def PrinterMoreInfoManufacturer(val): … … 175 175 """ 176 176 177 raise ClientErrorAttributes, "printer-more-info-manufacturer"177 raise errors.ClientErrorAttributes, "printer-more-info-manufacturer" 178 178 179 179 def PrinterState(val): … … 219 219 """ 220 220 221 raise ClientErrorAttributes, "printer-state-message"221 raise errors.ClientErrorAttributes, "printer-state-message" 222 222 223 223 def IppVersionsSupported(*vals): … … 462 462 """ 463 463 464 raise ClientErrorAttributes, "printer-message-from-operator"464 raise errors.ClientErrorAttributes, "printer-message-from-operator" 465 465 466 466 def ColorSupported(val): … … 469 469 """ 470 470 471 raise ClientErrorAttributes, "color-supported"471 raise errors.ClientErrorAttributes, "color-supported" 472 472 473 473 def ReferenceUriSchemeSupported(val): … … 476 476 """ 477 477 478 raise ClientErrorAttributes, "reference-uri-scheme-supported"478 raise errors.ClientErrorAttributes, "reference-uri-scheme-supported" 479 479 480 480 def PdlOverrideSupported(val): … … 547 547 """ 548 548 549 raise ClientErrorAttributes, "printer-current-time"549 raise errors.ClientErrorAttributes, "printer-current-time" 550 550 551 551 def MultipleOperationTimeOut(val): … … 601 601 """ 602 602 603 raise ClientErrorAttributes, "job-k-octets-supported"603 raise errors.ClientErrorAttributes, "job-k-octets-supported" 604 604 605 605 def JobImpressionsSupported(val): … … 608 608 """ 609 609 610 raise ClientErrorAttributes, "job-impressions-supported"610 raise errors.ClientErrorAttributes, "job-impressions-supported" 611 611 612 612 def JobMediaSheetsSupported(val): … … 615 615 """ 616 616 617 raise ClientErrorAttributes, "job-media-sheets-supported"617 raise errors.ClientErrorAttributes, "job-media-sheets-supported" 618 618 619 619 def PagesPerMinute(val): … … 622 622 """ 623 623 624 raise ClientErrorAttributes, "pages-per-minute"624 raise errors.ClientErrorAttributes, "pages-per-minute" 625 625 626 626 def PagesPerMinuteColor(val): … … 629 629 """ 630 630 631 raise ClientErrorAttributes, "pages-per-minute-color"632 631 raise errors.ClientErrorAttributes, "pages-per-minute-color" 632 -
server/lib/gutenbach/ipp/core/constants.py
raded2d1 r793432f 1 1 __all__ = [ 2 'Misc ',2 'MiscConstants', 3 3 'JobStates', 4 4 'PrinterStates', 5 'Operation s',5 'OperationCodes', 6 6 'SuccessCodes', 7 7 'ClientErrorCodes', … … 17 17 ] 18 18 19 class Misc ():19 class MiscConstants(): 20 20 """Miscellaneous config options for the IPP server. 21 21 … … 53 53 def __init__(self): pass 54 54 55 class Operation s():55 class OperationCodes(): 56 56 """IPP and CUPS IPP Operations, as defined in various RFCs: 57 57 -
server/lib/gutenbach/ipp/operations/__init__.py
rb828a96 r793432f 1 from .. attributeimport Attribute2 from .. attributegroupimport AttributeGroup3 from .. requestimport Request4 from .. valueimport Value1 from .. import Attribute 2 from .. import AttributeGroup 3 from .. import Request 4 from .. import Value 5 5 from .. import errors 6 from .. import constants as consts7 from .. import object_attributes6 from .. import constants 7 from .. import attributes 8 8 9 9 def verify_operations(request): … … 25 25 # check operation attributes tag 26 26 op_attrs = request.attribute_groups[0] 27 if op_attrs.tag != const s.AttributeTags.OPERATION:27 if op_attrs.tag != constants.AttributeTags.OPERATION: 28 28 raise errors.ClientErrorBadRequest( 29 29 "Attribute group does not have OPERATION tag: 0x%x" % op_attrs.tag) … … 45 45 # check charset 46 46 charset_attr = op_attrs.attributes[0] 47 expected = object_attributes.AttributesCharset('utf-8')47 expected = attributes.AttributesCharset('utf-8') 48 48 if charset_attr != expected: 49 49 raise errors.ClientErrorBadRequest("%s != %s" % (charset_attr, expected)) … … 51 51 # check for attributes-natural-language 52 52 natlang_attr = op_attrs.attributes[1] 53 expected = object_attributes.AttributesNaturalLanguage('en-us')53 expected = attributes.AttributesNaturalLanguage('en-us') 54 54 if natlang_attr != expected: 55 55 raise errors.ClientErrorBadRequest("%s != %s" % (natlang_attr, expected)) … … 58 58 59 59 def verify_printer_uri(uri_attr): 60 expected = object_attributes.PrinterUri(uri_attr.values[0].value)60 expected = attributes.PrinterUri(uri_attr.values[0].value) 61 61 if uri_attr != expected: 62 62 raise errors.ClientErrorBadRequest("%s != %s" % (uri_attr, expected)) … … 70 70 71 71 def verify_requesting_username(username_attr): 72 expected = object_attributes.RequestingUserName(username_attr.values[0].value)72 expected = attributes.RequestingUserName(username_attr.values[0].value) 73 73 if username_attr != expected: 74 74 raise errors.ClientErrorBadRequest("%s != %s" % (username_attr, expected)) … … 77 77 def make_empty_response(request): 78 78 # Operation attributes -- typically the same for any request 79 attribute s= AttributeGroup(80 const s.AttributeTags.OPERATION,81 [ object_attributes.AttributesCharset('utf-8'),82 object_attributes.AttributesNaturalLanguage('en-us')])79 attribute_group = AttributeGroup( 80 constants.AttributeTags.OPERATION, 81 [attributes.AttributesCharset('utf-8'), 82 attributes.AttributesNaturalLanguage('en-us')]) 83 83 84 84 # Set up the default response -- handlers will override these … … 86 86 response_kwargs = {} 87 87 response_kwargs['version'] = request.version 88 response_kwargs['operation_id'] = const s.StatusCodes.OK88 response_kwargs['operation_id'] = constants.StatusCodes.OK 89 89 response_kwargs['request_id'] = request.request_id 90 response_kwargs['attribute_groups'] = [attribute s]90 response_kwargs['attribute_groups'] = [attribute_group] 91 91 response = Request(**response_kwargs) 92 92 … … 95 95 def make_job_attributes(attrs, request, response): 96 96 response.attribute_groups.append(AttributeGroup( 97 const s.AttributeTags.JOB, attrs))97 constants.AttributeTags.JOB, attrs)) 98 98 99 99 def make_printer_attributes(attrs, request, response): 100 100 response.attribute_groups.append(AttributeGroup( 101 const s.AttributeTags.PRINTER, attrs))101 constants.AttributeTags.PRINTER, attrs)) 102 102 103 103 from cups_get_classes import verify_cups_get_classes_request, make_cups_get_classes_response … … 125 125 from validate_job import verify_validate_job_request, make_validate_job_response 126 126 127 __all__ = ['verify_cups_get_classes_request', 'make_cups_get_classes_response' 128 'verify_cups_get_default_request', 'make_cups_get_default_response' 129 'verify_cups_get_document_request', 'make_cups_get_document_response' 130 'verify_cups_get_printers_request', 'make_cups_get_printers_response' 127 __all__ = ['verify_cups_get_classes_request', 'make_cups_get_classes_response', 128 'verify_cups_get_default_request', 'make_cups_get_default_response', 129 'verify_cups_get_document_request', 'make_cups_get_document_response', 130 'verify_cups_get_printers_request', 'make_cups_get_printers_response', 131 131 132 'verify_cancel_job_request', 'make_cancel_job_response' 133 'verify_create_job_request', 'make_create_job_response' 134 'verify_get_jobs_request', 'make_get_jobs_response' 135 'make_get_printer_attributes_response' 136 'verify_get_printer_attributes_request' 137 'verify_pause_printer_request', 'make_pause_printer_response' 138 'verify_print_job_request', 'make_print_job_response' 139 'verify_print_uri_request', 'make_print_uri_response' 140 'verify_promote_job_request', 'make_promote_job_response' 141 'verify_restart_job_request', 'make_restart_job_response' 142 'verify_resume_printer_request', 'make_resume_printer_response' 143 'verify_send_document_request', 'make_send_document_response' 144 'verify_send_uri_request', 'make_send_uri_response' 145 'make_set_job_attributes_response' 146 'verify_set_job_attributes_request' 147 'make_set_printer_attributes_response' 148 'verify_set_printer_attributes_request' 149 'verify_validate_job_request', 'make_validate_job_response' 132 'verify_cancel_job_request', 'make_cancel_job_response', 133 'verify_create_job_request', 'make_create_job_response', 134 'verify_get_jobs_request', 'make_get_jobs_response', 135 'make_get_printer_attributes_response', 136 'verify_get_printer_attributes_request', 137 'verify_pause_printer_request', 'make_pause_printer_response', 138 'verify_print_job_request', 'make_print_job_response', 139 'verify_print_uri_request', 'make_print_uri_response', 140 'verify_promote_job_request', 'make_promote_job_response', 141 'verify_restart_job_request', 'make_restart_job_response', 142 'verify_resume_printer_request', 'make_resume_printer_response', 143 'verify_send_document_request', 'make_send_document_response', 144 'verify_send_uri_request', 'make_send_uri_response', 145 'make_set_job_attributes_response', 146 'verify_set_job_attributes_request', 147 'make_set_printer_attributes_response', 148 'verify_set_printer_attributes_request', 149 'verify_validate_job_request', 'make_validate_job_response', 150 150 151 151 'verify_operations',
Note: See TracChangeset
for help on using the changeset viewer.