Changeset b828a96 for server/lib
- Timestamp:
- Dec 23, 2011, 9:04:31 PM (12 years ago)
- Branches:
- no-cups
- Children:
- 793432f
- Parents:
- aded2d1
- git-author:
- Jessica B. Hamrick <jhamrick@…> (12/23/11 21:04:31)
- git-committer:
- Jessica B. Hamrick <jhamrick@…> (12/23/11 21:04:31)
- Location:
- server/lib/gutenbach
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
server/lib/gutenbach/ipp/__init__.py
raded2d1 rb828a96 18 18 __all__.extend(constants.__all__) 19 19 20 import e xceptions as errors20 import errors 21 21 __all__.append('errors') 22 22 -
server/lib/gutenbach/ipp/attribute.py
rcad7502 rb828a96 70 70 self.name = name 71 71 self.values = values 72 73 def __cmp__(self, other): 74 eq = self.name == other.name 75 for v1, v2 in zip(self.values, other.values): 76 eq = eq and (v1 == v2) 77 return 0 if eq else 1 72 78 73 79 @property -
server/lib/gutenbach/ipp/attributegroup.py
rb2e077a rb828a96 40 40 self.attributes = [] 41 41 self.extend(attributes) 42 43 def __cmp__(self, other): 44 eq = self.tag == other.tag 45 for a1, a2 in zip(self.attributes, other.attributes): 46 eq = eq and (a1 == a2) 47 return 0 if eq else 1 42 48 43 49 def __getitem__(self, name): -
server/lib/gutenbach/ipp/object_attributes/__init__.py
raded2d1 rb828a96 2 2 from job_description_attributes import * 3 3 from printer_description_attributes import * 4 from operation_attributes import * 4 5 5 6 __all__ = ['job_template_attributes', 6 7 'job_description_attributes', 7 'printer_description_attributes'] 8 'printer_description_attributes', 9 'operation_attributes'] 8 10 __all__.extend(job_template_attributes.__all__) 9 11 __all__.extend(job_description_attributes.__all__) 10 12 __all__.extend(printer_description_attributes.__all__) 13 __all__.extend(operation_attributes.__all__) -
server/lib/gutenbach/ipp/object_attributes/job_description_attributes.py
raded2d1 rb828a96 37 37 from ..constants import * 38 38 39 class JobUri(Attribute):39 def JobUri(val): 40 40 """4.3.1 job-uri (uri) 41 41 … … 61 61 """ 62 62 63 def __init__(self, val): 64 super(type(self), self).__init__( 65 'job-uri', 66 [Value(CharacterStringTags.URI, val)]) 67 68 class JobId(Attribute): 63 return Attribute( 64 'job-uri', 65 [Value(CharacterStringTags.URI, val)]) 66 67 def JobId(val): 69 68 """4.3.2 job-id (integer(1:MAX)) 70 69 … … 82 81 """ 83 82 84 def __init__(self, val): 85 super(type(self), self).__init__( 86 'job-id', 87 [Value(IntegerTags.INTEGER, val)]) 88 89 class JobPrinterUri(Attribute): 83 return Attribute( 84 'job-id', 85 [Value(IntegerTags.INTEGER, val)]) 86 87 def JobPrinterUri(val): 90 88 """4.3.3 job-printer-uri (uri) 91 89 … … 105 103 """ 106 104 107 def __init__(self, val): 108 super(type(self), self).__init__( 109 'job-printer-uri', 110 [Value(CharacterStringTags.URI, val)]) 111 112 class JobMoreInfo(Attribute): 105 return Attribute( 106 'job-printer-uri', 107 [Value(CharacterStringTags.URI, val)]) 108 109 def JobMoreInfo(val): 113 110 """4.3.4 job-more-info (uri) 114 111 115 112 """ 116 113 117 def __init__(self, val): 118 raise ClientErrorAttributes, "job-more-info" 119 120 class JobName(Attribute): 114 raise ClientErrorAttributes, "job-more-info" 115 116 def JobName(val): 121 117 """4.3.5 job-name (name(MAX)) 122 118 … … 138 134 """ 139 135 140 def __init__(self, val): 141 super(type(self), self).__init__( 142 'job-name', 143 [Value(CharacterStringTags.NAME_WITHOUT_LANGUAGE, val)]) 144 145 class JobOriginatingUserName(Attribute): 136 return Attribute( 137 'job-name', 138 [Value(CharacterStringTags.NAME_WITHOUT_LANGUAGE, val)]) 139 140 def JobOriginatingUserName(val): 146 141 """4.3.6 job-originating-user-name (name(MAX)) 147 142 … … 163 158 """ 164 159 165 def __init__(self, val): 166 super(type(self), self).__init__( 167 'job-originating-user-name', 168 [Value(CharacterStringTags.NAME_WITHOUT_LANGUAGE, val)]) 169 170 class JobState(Attribute): 160 return Attribute( 161 'job-originating-user-name', 162 [Value(CharacterStringTags.NAME_WITHOUT_LANGUAGE, val)]) 163 164 def JobState(val): 171 165 """4.3.7 job-state (type1 enum) 172 166 … … 181 175 """ 182 176 183 def __init__(self, val): 184 super(type(self), self).__init__( 185 'job-state', 186 [Value(IntegerTags.ENUM, val)]) 187 188 class JobStateReasons(Attribute): 177 return Attribute( 178 'job-state', 179 [Value(IntegerTags.ENUM, val)]) 180 181 def JobStateReasons(val): 189 182 """4.3.8 job-state-reasons (1setOf type2 keyword) 190 183 … … 212 205 """ 213 206 214 def __init__(self, *vals): 215 super(type(self), self).__init__( 216 'job-state-reasons', 217 [Value(CharacterStringTags.KEYWORD, val) for val in vals]) 218 219 class JobStateMessage(Attribute): 207 return Attribute( 208 'job-state-reasons', 209 [Value(CharacterStringTags.KEYWORD, val) for val in vals]) 210 211 def JobStateMessage(val): 220 212 """4.3.9 job-state-message (text(MAX)) 221 213 222 214 """ 223 215 224 def __init__(self, val): 225 raise ClientErrorAttributes, "job-state-message" 226 227 class JobDetailedStatusMessages(Attribute): 216 raise ClientErrorAttributes, "job-state-message" 217 218 def JobDetailedStatusMessages(val): 228 219 """4.3.10 job-detailed-status-messages (1setOf text(MAX)) 229 220 230 221 """ 231 222 232 def __init__(self, *vals): 233 raise ClientErrorAttributes, "job-detailed-status-messages" 234 235 class JobDocumentAccessErrors(Attribute): 223 raise ClientErrorAttributes, "job-detailed-status-messages" 224 225 def JobDocumentAccessErrors(val): 236 226 """4.3.11 job-document-access-errors (1setOf text(MAX)) 237 227 238 228 """ 239 229 240 def __init__(self, *vals): 241 raise ClientErrorAttributes, "job-document-access-errors" 242 243 class NumberOfDocuments(Attribute): 230 raise ClientErrorAttributes, "job-document-access-errors" 231 232 def NumberOfDocuments(val): 244 233 """4.3.12 number-of-documents (integer(0:MAX)) 245 234 246 235 """ 247 236 248 def __init__(self, val): 249 raise ClientErrorAttributes, "number-of-documents" 250 251 class OutputDeviceAssigned(Attribute): 237 raise ClientErrorAttributes, "number-of-documents" 238 239 def OutputDeviceAssigned(val): 252 240 """4.3.13 output-device-assigned (name(127)) 253 241 254 242 """ 255 243 256 def __init__(self, val): 257 raise ClientErrorAttributes, "output-device-assigned" 258 259 class TimeAtCreation(Attribute): 244 raise ClientErrorAttributes, "output-device-assigned" 245 246 def TimeAtCreation(val): 260 247 """4.3.14.1 time-at-creation (integer(MIN:MAX)) 261 248 … … 265 252 """ 266 253 267 def __init__(self, val): 268 super(type(self), self).__init__( 269 "time-at-creation", 270 [Value(IntegerTags.INTEGER, val)]) 271 272 class TimeAtProcessing(Attribute): 254 return Attribute( 255 "time-at-creation", 256 [Value(IntegerTags.INTEGER, val)]) 257 258 def TimeAtProcessing(val): 273 259 """4.3.14.2 time-at-processing (integer(MIN:MAX)) 274 260 … … 281 267 """ 282 268 283 def __init__(self, val): 284 super(type(self), self).__init__( 285 "time-at-processing", 286 [Value(IntegerTags.INTEGER, val)]) 287 288 class TimeAtCompleted(Attribute): 269 return Attribute( 270 "time-at-processing", 271 [Value(IntegerTags.INTEGER, val)]) 272 273 def TimeAtCompleted(val): 289 274 """4.3.14.3 time-at-completed (integer(MIN:MAX)) 290 275 … … 296 281 """ 297 282 298 def __init__(self, val): 299 super(type(self), self).__init__( 300 "time-at-completed", 301 [Value(IntegerTags.INTEGER, val)]) 302 303 class JobPrinterUpTime(Attribute): 283 return Attribute( 284 "time-at-completed", 285 [Value(IntegerTags.INTEGER, val)]) 286 287 def JobPrinterUpTime(val): 304 288 """4.3.14.4 job-printer-up-time (integer(1:MAX)) 305 289 … … 321 305 """ 322 306 323 def __init__(self, val): 324 super(type(self), self).__init__( 325 "job-printer-up-time", 326 [Value(IntegerTags.INTEGER, val)]) 327 328 329 class DateTimeAtCreation(Attribute): 307 return Attribute( 308 "job-printer-up-time", 309 [Value(IntegerTags.INTEGER, val)]) 310 311 312 def DateTimeAtCreation(val): 330 313 """4.3.14.5 date-time-at-creation (dateTime) 331 314 332 315 """ 333 316 334 def __init__(self, val): 335 raise ClientErrorAttributes, "date-time-at-creation" 336 337 class DateTimeAtProcessing(Attribute): 317 raise ClientErrorAttributes, "date-time-at-creation" 318 319 def DateTimeAtProcessing(val): 338 320 """4.3.14.6 date-time-at-processing (dateTime) 339 321 340 322 """ 341 323 342 def __init__(self, val): 343 raise ClientErrorAttributes, "date-time-at-processing" 344 345 class DateTimeAtCompletion(Attribute): 324 raise ClientErrorAttributes, "date-time-at-processing" 325 326 def DateTimeAtCompletion(val): 346 327 """4.3.14.7 date-time-at-completed (dateTime) 347 328 348 329 """ 349 330 350 def __init__(self, val): 351 raise ClientErrorAttributes, "date-time-at-completion" 352 353 class NumberOfInterveningJobs(Attribute): 331 raise ClientErrorAttributes, "date-time-at-completion" 332 333 def NumberOfInterveningJobs(val): 354 334 """4.3.15 number-of-intervening-jobs (integer(0:MAX)) 355 335 356 336 """ 357 337 358 def __init__(self, val): 359 raise ClientErrorAttributes, "number-of-intervening-jobs" 360 361 class JobMessageFromOperator(Attribute): 338 raise ClientErrorAttributes, "number-of-intervening-jobs" 339 340 def JobMessageFromOperator(val): 362 341 """4.3.16 job-message-from-operator (text(127)) 363 342 364 343 """ 365 344 366 def __init__(self, val): 367 raise ClientErrorAttributes, "job-message-from-operator" 368 369 class JobKOctets(Attribute): 345 raise ClientErrorAttributes, "job-message-from-operator" 346 347 def JobKOctets(val): 370 348 """4.3.17.1 job-k-octets (integer(0:MAX)) 371 349 … … 392 370 """ 393 371 394 def __init__(self, val): 395 super(type(self), self).__init__( 396 'job-k-octets', 397 [Value(IntegerTags.INTEGER, val)]) 398 399 class JobImpressions(Attribute): 372 return Attribute( 373 'job-k-octets', 374 [Value(IntegerTags.INTEGER, val)]) 375 376 def JobImpressions(val): 400 377 """4.3.17.2 job-impressions (integer(0:MAX)) 401 378 402 379 """ 403 380 404 def __init__(self, val): 405 raise ClientErrorAttributes, "job-impressions" 406 407 class JobMediaSheets(Attribute): 381 raise ClientErrorAttributes, "job-impressions" 382 383 def JobMediaSheets(val): 408 384 """4.3.17.3 job-media-sheets (integer(0:MAX)) 409 385 410 386 """ 411 387 412 def __init__(self, val): 413 raise ClientErrorAttributes, "job-media-sheets" 414 415 class JobKOctetsProcessed(Attribute): 388 raise ClientErrorAttributes, "job-media-sheets" 389 390 def JobKOctetsProcessed(val): 416 391 """4.3.18.1 job-k-octets-processed (integer(0:MAX)) 417 392 418 393 """ 419 394 420 def __init__(self, val): 421 raise ClientErrorAttributes, "job-k-octets-processed" 422 423 class JobImpressionsCompleted(Attribute): 395 raise ClientErrorAttributes, "job-k-octets-processed" 396 397 def JobImpressionsCompleted(val): 424 398 """4.3.18.2 job-impressions-completed (integer(0:MAX)) 425 399 426 400 """ 427 401 428 def __init__(self, val): 429 raise ClientErrorAttributes, "job-impressions-completed" 430 431 class JobMediaSheetsCompleted(Attribute): 402 raise ClientErrorAttributes, "job-impressions-completed" 403 404 def JobMediaSheetsCompleted(val): 432 405 """4.3.18.3 job-media-sheets-completed (integer(0:MAX)) 433 406 434 407 """ 435 408 436 def __init__(self, val): 437 raise ClientErrorAttributes, "job-media-sheets-completed" 438 439 class AttributesCharset(Attribute): 409 raise ClientErrorAttributes, "job-media-sheets-completed" 410 411 def AttributesCharset(val): 440 412 """4.3.19 attributes-charset (charset) 441 413 … … 456 428 """ 457 429 458 def __init__(self, val): 459 super(type(self), self).__init__( 460 'attributes-charset', 461 [Value(CharacterStringTags.CHARSET, val)]) 462 463 class AttributesNaturalLanguage(Attribute): 430 return Attribute( 431 'attributes-charset', 432 [Value(CharacterStringTags.CHARSET, val)]) 433 434 def AttributesNaturalLanguage(val): 464 435 """4.3.20 attributes-natural-language (naturalLanguage) 465 436 … … 477 448 """ 478 449 479 def __init__(self, val): 480 super(type(self), self).__init__( 481 'attributes-natural-language', 482 [Value(CharacterStringTags.NATURAL_LANGUAGE, val)]) 450 return Attribute( 451 'attributes-natural-language', 452 [Value(CharacterStringTags.NATURAL_LANGUAGE, val)]) -
server/lib/gutenbach/ipp/object_attributes/job_template_attributes.py
raded2d1 rb828a96 19 19 from ..exceptions import ClientErrorAttributes 20 20 21 class JobPriority(Attribute):21 def JobPriority(val): 22 22 """4.2.1 job-priority (integer(1:100)) 23 23 … … 69 69 70 70 71 def __init__(self, val): 72 super(type(self), self).__init__( 73 'job-priority', 74 [Value(IntegerTags.INTEGER), val]) 71 return Attribute( 72 'job-priority', 73 [Value(IntegerTags.INTEGER), val]) 75 74 76 class JobHoldUntil(Attribute):75 def JobHoldUntil(val): 77 76 """4.2.2 job-hold-until (type3 keyword | name (MAX)) 78 77 79 78 """ 80 79 81 def __init__(self, val): 82 raise ClientErrorAttributes, "job-hold-until" 83 84 class JobSheets(Attribute): 80 raise ClientErrorAttributes, "job-hold-until" 81 82 def JobSheets(val): 85 83 """4.2.3 job-sheets (type3 keyword | name(MAX)) 86 84 87 85 """ 86 87 raise ClientErrorAttributes, "job-sheets" 88 88 89 def __init__(self, val): 90 raise ClientErrorAttributes, "job-sheets" 91 92 class MultipleDocumentHandling(Attribute): 89 def MultipleDocumentHandling(val): 93 90 """4.2.4 multiple-document-handling (type2 keyword) 94 91 95 92 """ 96 93 97 def __init__(self, val): 98 raise ClientErrorAttributes, "multiple-document-handling" 94 raise ClientErrorAttributes, "multiple-document-handling" 99 95 100 class Copies(Attribute):96 def Copies(val): 101 97 """4.2.5 copies (integer(1:MAX)) 102 98 103 99 """ 100 101 raise ClientErrorAttributes, "copies" 104 102 105 def __init__(self, val): 106 raise ClientErrorAttributes, "copies" 107 108 class Finishings(Attribute): 103 def Finishings(*vals): 109 104 """4.2.6 finishings (1setOf type2 enum) 110 105 111 106 """ 112 107 113 def __init__(self, *vals): 114 raise ClientErrorAttributes, "finishings" 108 raise ClientErrorAttributes, "finishings" 115 109 116 class PageRanges(Attribute):110 def PageRanges(*vals): 117 111 """4.2.7 page-ranges (1setOf rangeOfInteger (1:MAX)) 118 112 119 113 """ 120 114 121 def __init__(self, *vals): 122 raise ClientErrorAttributes, "page-ranges" 115 raise ClientErrorAttributes, "page-ranges" 123 116 124 class Sides(Attribute):117 def Sides(val): 125 118 """4.2.8 sides (type2 keyword) 126 119 127 120 """ 128 121 129 def __init__(self, val): 130 raise ClientErrorAttributes, "sides" 122 raise ClientErrorAttributes, "sides" 131 123 132 class NumberUp(Attribute):124 def NumberUp(val): 133 125 """4.2.9 number-up (integer(1:MAX)) 134 126 135 127 """ 136 128 137 def __init__(self, val): 138 raise ClientErrorAttributes, "number-up" 129 raise ClientErrorAttributes, "number-up" 139 130 140 class OrientationRequested(Attribute):131 def OrientationRequested(val): 141 132 """4.2.10 orientation-requested (type2 enum) 142 133 143 134 """ 144 135 145 def __init__(self, val): 146 raise ClientErrorAttributes, "orientation-requested" 136 raise ClientErrorAttributes, "orientation-requested" 147 137 148 class Media(Attribute):138 def Media(val): 149 139 """4.2.11 media (type3 keyword | name(MAX)) 150 140 151 141 """ 152 142 153 def __init__(self, val): 154 raise ClientErrorAttributes, "media" 143 raise ClientErrorAttributes, "media" 155 144 156 145 ### XXX: we may want to repurpose this for bitrate? 157 class PrinterResolution(Attribute):146 def PrinterResolution(val): 158 147 """4.2.12 printer-resolution (resolution) 159 148 160 149 """ 161 150 162 def __init__(self, val): 163 raise ClientErrorAttributes, "printer-resolution" 151 raise ClientErrorAttributes, "printer-resolution" 164 152 165 class PrintQuality(Attribute):153 def PrintQuality(val): 166 154 """4.2.13 print-quality (type2 enum) 167 155 168 156 """ 169 157 170 def __init__(self, val): 171 raise ClientErrorAttributes, "print-quality" 158 raise ClientErrorAttributes, "print-quality" -
server/lib/gutenbach/ipp/object_attributes/operation_attributes.py
raded2d1 rb828a96 9 9 from ..constants import * 10 10 11 class PrinterUri(Attribute): 12 def __init__(self, val): 13 super(type(self), self).__init__( 14 'printer-uri', 15 [Value(CharacterStringTags.URI, val)]) 11 def PrinterUri(val): 12 return Attribute( 13 'printer-uri', 14 [Value(CharacterStringTags.URI, val)]) 16 15 17 class RequestingUserName(Attribute): 18 def __init__(self, val): 19 super(type(self), self).__init__( 20 'requesting-user-name', 21 [Value(CharacterStringTags.NAME_WITHOUT_LANGUAGE, val)]) 16 def RequestingUserName(val): 17 return Attribute( 18 'requesting-user-name', 19 [Value(CharacterStringTags.NAME_WITHOUT_LANGUAGE, val)]) -
server/lib/gutenbach/ipp/object_attributes/printer_description_attributes.py
raded2d1 rb828a96 44 44 from ..constants import * 45 45 46 class PrinterUriSupported(Attribute):46 def PrinterUriSupported(*vals): 47 47 """4.4.1 printer-uri-supported (1setOf uri) 48 48 … … 63 63 """ 64 64 65 def __init__(self, *vals): 66 super(type(self), self).__init__( 67 'printer-uri-supported', 68 [Value(CharacterStringTags.URI, val) for val in vals]) 69 70 71 class UriAuthenticationSupported(Attribute): 65 return Attribute( 66 'printer-uri-supported', 67 [Value(CharacterStringTags.URI, val) for val in vals]) 68 69 70 def UriAuthenticationSupported(*vals): 72 71 """4.4.2 uri-authentication-supported (1setOf type2 keyword) 73 72 … … 86 85 """ 87 86 88 def __init__(self, val): 89 super(type(self), self).__init__( 90 'uri-authentication-supported', 91 [Value(CharacterStringTags.KEYWORD, val)]) 92 93 class UriSecuritySupported(Attribute): 87 return Attribute( 88 'uri-authentication-supported', 89 [Value(CharacterStringTags.KEYWORD, val) for val in vals]) 90 91 def UriSecuritySupported(*vals): 94 92 """4.4.3 uri-security-supported (1setOf type2 keyword) 95 93 … … 117 115 """ 118 116 119 def __init__(self, val): 120 super(type(self), self).__init__( 121 'uri-security-supported', 122 [Value(CharacterStringTags.KEYWORD, val)]) 123 124 class PrinterName(Attribute): 117 return Attribute( 118 'uri-security-supported', 119 [Value(CharacterStringTags.KEYWORD, val) for val in vals]) 120 121 def PrinterName(val): 125 122 """4.4.4 printer-name (name(127)) 126 123 … … 134 131 """ 135 132 136 def __init__(self, val): 137 super(type(self), self).__init__( 138 'printer-name', 139 [Value(CharacterStringTags.NAME_WITHOUT_LANGUAGE, val)]) 140 141 class PrinterLocation(Attribute): 133 return Attribute( 134 'printer-name', 135 [Value(CharacterStringTags.NAME_WITHOUT_LANGUAGE, val)]) 136 137 def PrinterLocation(val): 142 138 """4.4.5 printer-location (text(127)) 143 139 144 140 """ 145 141 146 def __init__(self, val): 147 raise ClientErrorAttributes, "printer-location" 148 149 class PrinterInfo(Attribute): 142 raise ClientErrorAttributes, "printer-location" 143 144 def PrinterInfo(val): 150 145 """4.4.6 printer-info (text(127)) 151 146 152 147 """ 153 148 154 def __init__(self, val): 155 raise ClientErrorAttributes, "printer-info" 156 157 class PrinterMoreInfo(Attribute): 149 raise ClientErrorAttributes, "printer-info" 150 151 def PrinterMoreInfo(val): 158 152 """4.4.7 printer-more-info (uri) 159 153 160 154 """ 161 155 162 def __init__(self, val): 163 raise ClientErrorAttributes, "printer-more-info" 164 165 class PrinterDriverInstaller(Attribute): 156 raise ClientErrorAttributes, "printer-more-info" 157 158 def PrinterDriverInstaller(val): 166 159 """4.4.8 printer-driver-installer (uri) 167 160 168 161 """ 169 162 170 def __init__(self, val): 171 raise ClientErrorAttributes, "printer-driver-installer" 172 173 class PrinterMakeAndModel(Attribute): 163 raise ClientErrorAttributes, "printer-driver-installer" 164 165 def PrinterMakeAndModel(val): 174 166 """4.4.9 printer-make-and-model (text(127)) 175 167 176 168 """ 177 169 178 def __init__(self, val): 179 raise ClientErrorAttributes, "printer-make-and-model" 180 181 class PrinterMoreInfoManufacturer(Attribute): 170 raise ClientErrorAttributes, "printer-make-and-model" 171 172 def PrinterMoreInfoManufacturer(val): 182 173 """4.4.10 printer-more-info-manufacturer (uri) 183 174 184 175 """ 185 176 186 def __init__(self, val): 187 raise ClientErrorAttributes, "printer-more-info-manufacturer" 188 189 class PrinterState(Attribute): 177 raise ClientErrorAttributes, "printer-more-info-manufacturer" 178 179 def PrinterState(val): 190 180 """4.4.11 printer-state (type1 enum) 191 181 … … 203 193 """ 204 194 205 def __init__(self, val): 206 super(type(self), self).__init__( 207 'printer-state', 208 [Value(IntegerTags.ENUM, val)]) 209 210 class PrinterStateReasons(Attribute): 195 return Attribute( 196 'printer-state', 197 [Value(IntegerTags.ENUM, val)]) 198 199 def PrinterStateReasons(*vals): 211 200 """4.4.12 printer-state-reasons (1setOf type2 keyword) 212 201 … … 221 210 """ 222 211 223 def __init__(self, val): 224 super(type(self), self).__init__( 225 'printer-state-reasons', 226 [Value(CharacterStringTags.KEYWORD, val)]) 227 228 class PrinterStateMessage(Attribute): 212 return Attribute( 213 'printer-state-reasons', 214 [Value(CharacterStringTags.KEYWORD, val) for val in vals]) 215 216 def PrinterStateMessage(val): 229 217 """4.4.13 printer-state-message (text(MAX)) 230 218 231 219 """ 232 220 233 def __init__(self, val): 234 raise ClientErrorAttributes, "printer-state-message" 235 236 class IppVersionsSupported(Attribute): 221 raise ClientErrorAttributes, "printer-state-message" 222 223 def IppVersionsSupported(*vals): 237 224 """4.4.14 ipp-versions-supported (1setOf type2 keyword) 238 225 … … 266 253 """ 267 254 268 def __init__(self, *vals): 269 super(type(self), self).__init__( 270 'ipp-versions-supported', 271 [Value(CharacterStringTags.KEYWORD, val) for val in vals]) 272 273 class OperationsSupported(Attribute): 255 return Attribute( 256 'ipp-versions-supported', 257 [Value(CharacterStringTags.KEYWORD, val) for val in vals]) 258 259 def OperationsSupported(*vals): 274 260 """4.4.15 operations-supported (1setOf type2 enum) 275 261 … … 286 272 """ 287 273 288 def __init__(self, *vals): 289 super(type(self), self).__init__( 290 'operations-supported', 291 [Value(IntegerTags.ENUM, val) for val in vals]) 292 293 class MultipleDocumentJobsSupported(Attribute): 274 return Attribute( 275 'operations-supported', 276 [Value(IntegerTags.ENUM, val) for val in vals]) 277 278 def MultipleDocumentJobsSupported(val): 294 279 """4.4.16 multiple-document-jobs-supported (boolean) 295 280 … … 302 287 """ 303 288 304 def __init__(self, val): 305 super(type(self), self).__init__( 306 'multiple-document-jobs-supported', 307 [Value(IntegerTags.BOOLEAN, val)]) 308 309 class CharsetConfigured(Attribute): 289 return Attribute( 290 'multiple-document-jobs-supported', 291 [Value(IntegerTags.BOOLEAN, val)]) 292 293 def CharsetConfigured(val): 310 294 """4.4.17 charset-configured (charset) 311 295 … … 321 305 """ 322 306 323 def __init__(self, val): 324 super(type(self), self).__init__( 325 'charset-configured', 326 [Value(CharacterStringTags.CHARSET, val)]) 327 328 class CharsetSupported(Attribute): 307 return Attribute( 308 'charset-configured', 309 [Value(CharacterStringTags.CHARSET, val)]) 310 311 def CharsetSupported(*vals): 329 312 """4.4.18 charset-supported (1setOf charset) 330 313 … … 344 327 """ 345 328 346 def __init__(self, *vals): 347 super(type(self), self).__init__( 348 'charset-supported', 349 [Value(CharacterStringTags.CHARSET, val) for val in vals]) 350 351 class NaturalLanguageConfigured(Attribute): 329 return Attribute( 330 'charset-supported', 331 [Value(CharacterStringTags.CHARSET, val) for val in vals]) 332 333 def NaturalLanguageConfigured(val): 352 334 """4.4.19 natural-language-configured (naturalLanguage) 353 335 … … 370 352 """ 371 353 372 def __init__(self, val): 373 super(type(self), self).__init__( 374 'natural-language-configured', 375 [Value(CharacterStringTags.NATURAL_LANGUAGE, val)]) 376 377 class GeneratedNaturalLanguageSupported(Attribute): 354 return Attribute( 355 'natural-language-configured', 356 [Value(CharacterStringTags.NATURAL_LANGUAGE, val)]) 357 358 def GeneratedNaturalLanguageSupported(*vals): 378 359 """4.4.20 generated-natural-language-supported (1setOf naturalLanguage) 379 360 … … 402 383 """ 403 384 404 def __init__(self, *vals): 405 super(type(self), self).__init__( 406 'generated-natural-language-supported', 407 [Value(CharacterStringTags.NATURAL_LANGUAGE, val) for val in vals]) 408 409 class DocumentFormatDefault(Attribute): 385 return Attribute( 386 'generated-natural-language-supported', 387 [Value(CharacterStringTags.NATURAL_LANGUAGE, val) for val in vals]) 388 389 def DocumentFormatDefault(val): 410 390 """4.4.21 document-format-default (mimeMediaType) 411 391 … … 421 401 """ 422 402 423 def __init__(self, val): 424 super(type(self), self).__init__( 425 'document-format-default', 426 [Value(CharacterStringTags.MIME_MEDIA_TYPE, val)]) 427 428 class DocumentFormatSupported(Attribute): 403 return Attribute( 404 'document-format-default', 405 [Value(CharacterStringTags.MIME_MEDIA_TYPE, val)]) 406 407 def DocumentFormatSupported(*vals): 429 408 """4.4.22 document-format-supported (1setOf mimeMediaType) 430 409 … … 436 415 """ 437 416 438 def __init__(self, *vals): 439 super(type(self), self).__init__( 440 'document-format-supported', 441 [Value(CharacterStringTags.MIME_MEDIA_TYPE, val) for val in vals]) 442 443 class PrinterIsAcceptingJobs(Attribute): 417 return Attribute( 418 'document-format-supported', 419 [Value(CharacterStringTags.MIME_MEDIA_TYPE, val) for val in vals]) 420 421 def PrinterIsAcceptingJobs(val): 444 422 """4.4.23 printer-is-accepting-jobs (boolean) 445 423 … … 462 440 """ 463 441 464 def __init__(self, val): 465 super(type(self), self).__init__( 466 'printer-is-accepting-jobs', 467 [Value(IntegerTags.BOOLEAN, val)]) 468 469 class QueuedJobCount(Attribute): 442 return Attribute( 443 'printer-is-accepting-jobs', 444 [Value(IntegerTags.BOOLEAN, val)]) 445 446 def QueuedJobCount(val): 470 447 """4.4.24 queued-job-count (integer(0:MAX)) 471 448 … … 476 453 """ 477 454 478 def __init__(self, val): 479 super(type(self), self).__init__( 480 'queued-job-count', 481 [Value(IntegerTags.INTEGER, val)]) 482 483 class PrinterMessageFromOperator(Attribute): 455 return Attribute( 456 'queued-job-count', 457 [Value(IntegerTags.INTEGER, val)]) 458 459 def PrinterMessageFromOperator(val): 484 460 """4.4.25 printer-message-from-operator (text(127)) 485 461 486 462 """ 487 463 488 def __init__(self, val): 489 raise ClientErrorAttributes, "printer-message-from-operator" 490 491 class ColorSupported(Attribute): 464 raise ClientErrorAttributes, "printer-message-from-operator" 465 466 def ColorSupported(val): 492 467 """4.4.26 color-supported (boolean) 493 468 494 469 """ 495 470 496 def __init__(self, val): 497 raise ClientErrorAttributes, "color-supported" 498 499 class ReferenceUriSchemeSupported(Attribute): 471 raise ClientErrorAttributes, "color-supported" 472 473 def ReferenceUriSchemeSupported(val): 500 474 """4.4.27 reference-uri-schemes-supported (1setOf uriScheme) 501 475 502 476 """ 503 477 504 def __init__(self, *vals): 505 raise ClientErrorAttributes, "reference-uri-scheme-supported" 506 507 class PdlOverrideSupported(Attribute): 478 raise ClientErrorAttributes, "reference-uri-scheme-supported" 479 480 def PdlOverrideSupported(val): 508 481 """4.4.28 pdl-override-supported (type2 keyword) 509 482 … … 528 501 """ 529 502 530 def __init__(self, val): 531 super(type(self), self).__init__( 532 'pdl-override-supported', 533 [Value(CharacterStringTags.KEYWORD, val)]) 534 535 class PrinterUpTime(Attribute): 503 return Attribute( 504 'pdl-override-supported', 505 [Value(CharacterStringTags.KEYWORD, val)]) 506 507 def PrinterUpTime(val): 536 508 """4.4.29 printer-up-time (integer(1:MAX)) 537 509 … … 566 538 """ 567 539 568 def __init__(self, val): 569 super(type(self), self).__init__( 570 'printer-up-time', 571 [Value(IntegerTags.INTEGER, val)]) 572 573 class PrinterCurrentTime(Attribute): 540 return Attribute( 541 'printer-up-time', 542 [Value(IntegerTags.INTEGER, val)]) 543 544 def PrinterCurrentTime(val): 574 545 """4.4.30 printer-current-time (dateTime) 575 546 576 547 """ 577 548 578 def __init__(self, val): 579 raise ClientErrorAttributes, "printer-current-time" 580 581 class MultipleOperationTimeOut(Attribute): 549 raise ClientErrorAttributes, "printer-current-time" 550 551 def MultipleOperationTimeOut(val): 582 552 """4.4.31 multiple-operation-time-out (integer(1:MAX)) 583 553 … … 598 568 """ 599 569 600 def __init__(self, val): 601 super(type(self), self).__init__( 602 'multiple-operation-time-out', 603 [Value(IntegerTags.INTEGER, val)]) 604 605 class CompressionSupported(Attribute): 570 return Attribute( 571 'multiple-operation-time-out', 572 [Value(IntegerTags.INTEGER, val)]) 573 574 def CompressionSupported(*vals): 606 575 """4.4.32 compression-supported (1setOf type3 keyword) 607 576 … … 623 592 """ 624 593 625 def __init__(self, *vals): 626 super(type(self), self).__init__( 627 'compression-supported', 628 [Value(CharacterStringTags.KEYWORD, val) for val in vals]) 629 630 class JobKOctetsSupported(Attribute): 594 return Attribute( 595 'compression-supported', 596 [Value(CharacterStringTags.KEYWORD, val) for val in vals]) 597 598 def JobKOctetsSupported(val): 631 599 """4.4.33 job-k-octets-supported (rangeOfInteger(0:MAX)) 632 600 633 601 """ 634 602 635 def __init__(self, val): 636 raise ClientErrorAttributes, "job-k-octets-supported" 637 638 class JobImpressionsSupported(Attribute): 603 raise ClientErrorAttributes, "job-k-octets-supported" 604 605 def JobImpressionsSupported(val): 639 606 """4.4.34 job-impressions-supported (rangeOfInteger(0:MAX)) 640 607 641 608 """ 642 609 643 def __init__(self, val): 644 raise ClientErrorAttributes, "job-impressions-supported" 645 646 class JobMediaSheetsSupported(Attribute): 610 raise ClientErrorAttributes, "job-impressions-supported" 611 612 def JobMediaSheetsSupported(val): 647 613 """4.4.35 job-media-sheets-supported (rangeOfInteger(0:MAX)) 648 614 649 615 """ 650 616 651 def __init__(self, val): 652 raise ClientErrorAttributes, "job-media-sheets-supported" 653 654 class PagesPerMinute(Attribute): 617 raise ClientErrorAttributes, "job-media-sheets-supported" 618 619 def PagesPerMinute(val): 655 620 """4.4.36 pages-per-minute (integer(0:MAX)) 656 621 657 622 """ 658 623 659 def __init__(self, val): 660 raise ClientErrorAttributes, "pages-per-minute" 661 662 class PagesPerMinuteColor(Attribute): 624 raise ClientErrorAttributes, "pages-per-minute" 625 626 def PagesPerMinuteColor(val): 663 627 """4.4.37 pages-per-minute-color (integer(0:MAX)) 664 628 665 629 """ 666 630 667 def __init__(self, val): 668 raise ClientErrorAttributes, "pages-per-minute-color" 669 631 raise ClientErrorAttributes, "pages-per-minute-color" 632 -
server/lib/gutenbach/ipp/operations/__init__.py
raded2d1 rb828a96 45 45 # check charset 46 46 charset_attr = op_attrs.attributes[0] 47 if charset_attr != object_attributes.AttributesCharset('utf-8'): 48 raise errors.ClientErrorBadRequest 47 expected = object_attributes.AttributesCharset('utf-8') 48 if charset_attr != expected: 49 raise errors.ClientErrorBadRequest("%s != %s" % (charset_attr, expected)) 49 50 50 51 # check for attributes-natural-language 51 52 natlang_attr = op_attrs.attributes[1] 52 if natlang_attr != object_attributes.AttributesNaturalLanguage('en-us'): 53 raise errors.ClientErrorBadRequest 53 expected = object_attributes.AttributesNaturalLanguage('en-us') 54 if natlang_attr != expected: 55 raise errors.ClientErrorBadRequest("%s != %s" % (natlang_attr, expected)) 54 56 55 57 return dict([(attr.name, attr) for attr in op_attrs.attributes]) 56 58 57 59 def verify_printer_uri(uri_attr): 58 if uri_attr != object_attributes.PrinterUri(uri_attr.values[0].value): 59 raise errors.ClientErrorBadRequest 60 expected = object_attributes.PrinterUri(uri_attr.values[0].value) 61 if uri_attr != expected: 62 raise errors.ClientErrorBadRequest("%s != %s" % (uri_attr, expected)) 60 63 61 64 # actually get the printer name … … 67 70 68 71 def verify_requesting_username(username_attr): 69 if username_attr != object_attributes.RequestingUserName(username_attr.values[0].value): 70 raise errors.ClientErrorBadRequest 72 expected = object_attributes.RequestingUserName(username_attr.values[0].value) 73 if username_attr != expected: 74 raise errors.ClientErrorBadRequest("%s != %s" % (username_attr, expected)) 71 75 return username_attr.values[0].value 72 76 … … 121 125 from validate_job import verify_validate_job_request, make_validate_job_response 122 126 123 124 125 127 __all__ = ['verify_cups_get_classes_request', 'make_cups_get_classes_response' 126 128 'verify_cups_get_default_request', 'make_cups_get_default_response' -
server/lib/gutenbach/ipp/value.py
r0c4f3bf rb828a96 54 54 self.tag = tag # one byte, the type of value 55 55 self.value = value # non-binary value of self.value 56 57 def __cmp__(self, other): 58 eq = (self.value == other.value) and (self.tag == other.tag) 59 return 0 if eq else 1 56 60 57 61 @classmethod -
server/lib/gutenbach/server/requests.py
raded2d1 rb828a96 53 53 except ipp.errors.IPPException: 54 54 exctype, excval, exctb = sys.exc_info() 55 logger.error( traceback.format_exc())55 logger.error("%s: %s" % (exctype.__name__, excval.message)) 56 56 response = ipp.ops.make_empty_response(request) 57 57 excval.update_response(response) … … 86 86 """ 87 87 88 raise NotImplementedError88 raise ipp.errors.ServerErrorOperationNotSupported 89 89 90 90 @handler_for(consts.Operations.VALIDATE_JOB) 91 91 def validate_job(self, request): 92 92 93 raise NotImplementedError93 raise ipp.errors.ServerErrorOperationNotSupported 94 94 95 95 @handler_for(consts.Operations.GET_JOBS) … … 129 129 @handler_for(consts.Operations.PRINT_URI) 130 130 def print_uri(self, request): 131 raise NotImplementedError131 raise ipp.errors.ServerErrorOperationNotSupported 132 132 133 133 @handler_for(consts.Operations.CREATE_JOB) … … 181 181 """ 182 182 183 raise NotImplementedError183 raise ipp.errors.ServerErrorOperationNotSupported 184 184 185 185 @handler_for(consts.Operations.PAUSE_PRINTER) 186 186 def pause_printer(self, request): 187 raise NotImplementedError187 raise ipp.errors.ServerErrorOperationNotSupported 188 188 189 189 @handler_for(consts.Operations.RESUME_PRINTER) 190 190 def resume_printer(self, request): 191 raise NotImplementedError191 raise ipp.errors.ServerErrorOperationNotSupported 192 192 193 193 @handler_for(consts.Operations.GET_PRINTER_ATTRIBUTES) … … 252 252 @handler_for(consts.Operations.SET_PRINTER_ATTRIBUTES) 253 253 def set_printer_attributes(self, request): 254 raise NotImplementedError254 raise ipp.errors.ServerErrorOperationNotSupported 255 255 256 256 ##### Job Commands … … 258 258 @handler_for(consts.Operations.CANCEL_JOB) 259 259 def cancel_job(self, request): 260 raise NotImplementedError260 raise ipp.errors.ServerErrorOperationNotSupported 261 261 262 262 @handler_for(consts.Operations.SEND_DOCUMENT) 263 263 def send_document(self, request): 264 raise NotImplementedError264 raise ipp.errors.ServerErrorOperationNotSupported 265 265 266 266 @handler_for(consts.Operations.SEND_URI) 267 267 def send_uri(self, request): 268 raise NotImplementedError268 raise ipp.errors.ServerErrorOperationNotSupported 269 269 270 270 @handler_for(consts.Operations.GET_JOB_ATTRIBUTES) … … 297 297 @handler_for(consts.Operations.SET_JOB_ATTRIBUTES) 298 298 def set_job_attributes(self, request): 299 raise NotImplementedError299 raise ipp.errors.ServerErrorOperationNotSupported 300 300 301 301 @handler_for(consts.Operations.RESTART_JOB) 302 302 def restart_job(self, request): 303 raise NotImplementedError303 raise ipp.errors.ServerErrorOperationNotSupported 304 304 305 305 @handler_for(consts.Operations.PROMOTE_JOB) 306 306 def promote_job(self, request): 307 raise NotImplementedError307 raise ipp.errors.ServerErrorOperationNotSupported 308 308 309 309 ##### CUPS Specific Commands … … 311 311 @handler_for(consts.Operations.CUPS_GET_DOCUMENT) 312 312 def cups_get_document(self, request): 313 raise NotImplementedError313 raise ipp.errors.ServerErrorOperationNotSupported 314 314 315 315 @handler_for(consts.Operations.CUPS_GET_DEFAULT)
Note: See TracChangeset
for help on using the changeset viewer.