Changeset 9225351
- Timestamp:
- Jan 21, 2012, 4:36:37 PM (13 years ago)
- Branches:
- no-cups
- Children:
- 15fb0f8, 374c558
- Parents:
- fa3e2c6 (diff), 56fd535 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent. - git-author:
- Steven Allen <steven@…> (01/21/12 16:36:37)
- git-committer:
- Steven Allen <steven@…> (01/21/12 16:36:37)
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
server/lib/TODO
r20f7360 r56fd535 4 4 5 5 - finish implementing a bunch of the IPP handlers 6 [ ] print job 6 7 [ ] validate job 7 8 [ ] pause printer … … 15 16 16 17 - add support in printer.py for: 18 [ ] print job 17 19 [ ] validate job 18 20 [ ] pause printer 19 21 [ ] resume printer 20 [ 21 [ 22 [ 23 [ 24 [ 22 [\] set printer attributes 23 [\] send uri 24 [\] set job attributes 25 [X] restart job 26 [\] promote job 25 27 26 28 - add support in job.py for: 27 [ 29 [X] restart job 28 30 29 31 - finish test cases for printer.py … … 52 54 - local streaming 53 55 - generic streaming 56 - zephyr control (e.g. youtube link) 54 57 55 58 Tickets that should be fixed by this new version: -
server/lib/gutenbach/server/job.py
rcb0195f r9225351 383 383 384 384 def restart(self): 385 # XXX: Todo 386 pass 385 """Non-blocking restart. Job must be finished (see 386 'GutenbachJob.is_done'), and will be ready to be played (see 387 'GutenbachJob.is_ready') if this method is successful. 388 389 Raises 390 ------ 391 InvalidJobStateException 392 If the job is not done. 393 394 """ 395 396 if not self.is_done: 397 raise errors.InvalidJobStateException(self.state) 398 399 logger.debug("restarting job %d" % (self.id, self.document)) 400 401 self._why_done = None 402 self.spool(self.document) -
server/lib/gutenbach/server/printer.py
rfa3e2c6 r9225351 184 184 def printer_uri_supported(self): 185 185 return ipp.PrinterUriSupported(self.uri) 186 @printer_uri_supported.setter 187 def printer_uri_supported(self, val): 188 raise ipp.errors.AttributesNotSettable("printer-uri-supported") 186 189 187 190 @property 188 191 def uri_authentication_supported(self): 189 192 return ipp.UriAuthenticationSupported("none") 193 @uri_authentication_supported.setter 194 def uri_authentication_supported(self, val): 195 raise ipp.errors.AttributesNotSettable("uri-authentication-supported") 190 196 191 197 @property 192 198 def uri_security_supported(self): 193 199 return ipp.UriSecuritySupported("none") 200 @uri_security_supported.setter 201 def uri_security_supported(self, val): 202 raise ipp.errors.AttributesNotSettable("uri-security-supported") 194 203 195 204 @property 196 205 def printer_name(self): 197 206 return ipp.PrinterName(self.name) 207 @printer_name.setter 208 def printer_name(self, val): 209 raise ipp.errors.AttributesNotSettable("printer-name") 198 210 199 211 @property 200 212 def printer_state(self): 201 213 return ipp.PrinterState(self.state) 214 @printer_state.setter 215 def printer_state(self, val): 216 raise ipp.errors.AttributesNotSettable("printer-state") 202 217 203 218 @property 204 219 def printer_state_reasons(self): 205 220 return ipp.PrinterStateReasons("none") 221 @printer_state_reasons.setter 222 def printer_state_reasons(self, val): 223 raise ipp.errors.AttributesNotSettable("printer-state-reasons") 206 224 207 225 @property 208 226 def ipp_versions_supported(self): 209 227 return ipp.IppVersionsSupported(*self.config['ipp-versions']) 228 @ipp_versions_supported.setter 229 def ipp_versions_supported(self, val): 230 raise ipp.errors.AttributesNotSettable("ipp-versions-supported") 210 231 211 232 # XXX: We should query ourself for the supported operations … … 213 234 def operations_supported(self): 214 235 return ipp.OperationsSupported(ipp.OperationCodes.GET_JOBS) 236 @operations_supported.setter 237 def operations_supported(self, val): 238 raise ipp.errors.AttributesNotSettable("operations-supported") 215 239 216 240 @property 217 241 def charset_configured(self): 218 return ipp.CharsetConfigured("utf-8") 219 242 return ipp.CharsetConfigured("utf-8") # XXX 243 @charset_configured.setter 244 def charset_configured(self, val): 245 raise ipp.errors.AttributesNotSettable("charset-configured") 246 220 247 @property 221 248 def charset_supported(self): 222 return ipp.CharsetSupported("utf-8") 249 return ipp.CharsetSupported("utf-8") # XXX 250 @charset_supported.setter 251 def charset_supported(self, val): 252 raise ipp.errors.AttributesNotSettable("charset-supported") 223 253 224 254 @property 225 255 def natural_language_configured(self): 226 256 return ipp.NaturalLanguageConfigured("en-us") 257 @natural_language_configured.setter 258 def natural_language_configured(self, val): 259 raise ipp.errors.AttributesNotSettable("natural-language-configured") 227 260 228 261 @property 229 262 def generated_natural_language_supported(self): 230 263 return ipp.GeneratedNaturalLanguageSupported("en-us") 264 @generated_natural_language_supported.setter 265 def generated_natural_language_supported(self, val): 266 raise ipp.errors.AttributesNotSettable("generated-natural-language-supported") 231 267 232 268 @property 233 269 def document_format_default(self): 234 270 return ipp.DocumentFormatDefault("application/octet-stream") 271 @document_format_default.setter 272 def document_format_default(self, val): 273 raise ipp.errors.AttributesNotSettable("document-format-default") 235 274 236 275 @property 237 276 def document_format_supported(self): 238 277 return ipp.DocumentFormatSupported("application/octet-stream", "audio/mp3") 278 @document_format_supported.setter 279 def document_format_supported(self, val): 280 raise ipp.errors.AttributesNotSettable("document-format-supported") 239 281 240 282 @property 241 283 def printer_is_accepting_jobs(self): 242 284 return ipp.PrinterIsAcceptingJobs(True) 285 @printer_is_accepting_jobs.setter 286 def printer_is_accepting_jobs(self, val): 287 raise ipp.errors.AttributesNotSettable("printer-is-accepting-jobs") 243 288 244 289 @property 245 290 def queued_job_count(self): 246 291 return ipp.QueuedJobCount(len(self.active_jobs)) 292 @queued_job_count.setter 293 def queued_job_count(self, val): 294 raise ipp.errors.AttributesNotSettable("queued-job-count") 247 295 248 296 @property 249 297 def pdl_override_supported(self): 250 298 return ipp.PdlOverrideSupported("not-attempted") 299 @pdl_override_supported.setter 300 def pdl_override_supported(self, val): 301 raise ipp.errors.AttributesNotSettable("pdl-override-supported") 251 302 252 303 @property 253 304 def printer_up_time(self): 254 305 return ipp.PrinterUpTime(int(time.time()) - self.time_created) 306 @printer_up_time.setter 307 def printer_up_time(self, val): 308 raise ipp.errors.AttributesNotSettable("printer-up-time") 255 309 256 310 @property 257 311 def compression_supported(self): 258 312 return ipp.CompressionSupported("none") 313 @compression_supported.setter 314 def compression_supported(self, val): 315 raise ipp.errors.AttributesNotSettable("compression-supported") 259 316 260 317 @property 261 318 def multiple_operation_time_out(self): 262 319 return ipp.MultipleOperationTimeOut(240) 320 @multiple_operation_time_out.setter 321 def multiple_operation_time_out(self, val): 322 raise ipp.errors.AttributesNotSettable("multiple-operation-time-out") 263 323 264 324 @property 265 325 def multiple_document_jobs_supported(self): 266 326 return ipp.MultipleDocumentJobsSupported(False) 327 @multiple_document_jobs_supported.setter 328 def multiple_document_jobs_supported(self, val): 329 raise ipp.errors.AttributesNotSettable("multiple-document-jobs-supported") 267 330 268 331 ###################################################################### … … 389 452 return attributes 390 453 391 def set_printer_attributes(self): 392 pass 454 def set_printer_attributes(self, job_id, attributes): 455 for attr in attributes: 456 try: 457 setattr(self, attr, attributes[attr]) 458 except AttributeError: 459 raise ipp.errors.ClientErrorAttributes 393 460 394 461 def cancel_job(self, job_id, requesting_user_name=None): … … 408 475 job.spool(document) 409 476 410 def send_uri(self): 411 pass 477 def send_uri(self, job_id, document_uri, document_name=None, 478 document_format=None, document_natural_language=None, 479 requesting_user_name=None, compression=None, 480 last_document=None): 481 job = self.get_job(job_id) 482 # XXX: need to validate URI 483 # XXX: need to deal with the URI stream? 484 #job.spool_uri(document_uri) 412 485 413 486 def get_job_attributes(self, job_id, requested_attributes=None): … … 422 495 return attributes 423 496 424 def set_job_attributes(self): 425 pass 426 427 def restart_job(self): 428 pass 429 430 def promote_job(self): 431 pass 497 def set_job_attributes(self, job_id, attributes): 498 job = self.get_job(job_id) 499 for attr in attributes: 500 if attr in ("job-id", "job-k-octets", "job-state", "job-printer-uri"): 501 raise ipp.errors.ClientErrorAttributesNotSettable(attr) 502 elif attr == "job-name": 503 job.name = attributes[attr] 504 elif attr == "job-originating-user-name": 505 job.creator = attributes[attr] # XXX: do we want this? 506 507 def restart_job(self, job_id, requesting_user_name=None): 508 job = self.get_job(job_id) 509 try: 510 job.restart() 511 except InvalidJobStateException: 512 # XXX 513 raise ipp.errors.ClientErrorNotPossible 514 515 with self.lock: 516 self.finished_jobs.remove(job_id) 517 self.pending_jobs.append(job_id) 518 519 def promote_job(self, job_id, requesting_user_name=None): 520 # According to RFC 3998, we need to put the job at the front 521 # of the queue (so that when the currently playing job 522 # completes, this one will go next 523 524 job = self.get_job(job_id) 525 job.priority = 1 # XXX we need to actually do something 526 # correct here -
server/lib/gutenbach/server/requests.py
rd994f15 rc1dc25f 268 268 @handler_for(ipp.OperationCodes.PRINT_URI) 269 269 def print_uri(self, request, response): 270 """3.2.2 Print-URI Operation 271 272 This OPTIONAL operation is identical to the Print-Job operation 273 (section 3.2.1) except that a client supplies a URI reference to the 274 document data using the 'document-uri' (uri) operation attribute (in 275 Group 1) rather than including the document data itself. Before 276 returning the response, the Printer MUST validate that the Printer 277 supports the retrieval method (e.g., http, ftp, etc.) implied by the 278 URI, and MUST check for valid URI syntax. If the client-supplied URI 279 scheme is not supported, i.e. the value is not in the Printer 280 object's 'referenced-uri-scheme-supported' attribute, the Printer 281 object MUST reject the request and return the 'client-error-uri- 282 scheme-not-supported' status code. 283 284 The IPP Printer MAY validate the accessibility of the document as 285 part of the operation or subsequently. If the Printer determines an 286 accessibility problem before returning an operation response, it 287 rejects the request and returns the 'client-error-document-access- 288 error' status code. The Printer MAY also return a specific document 289 access error code using the 'document-access-error' operation 290 attribute (see section 3.1.6.4). 291 292 If the Printer determines this document accessibility problem after 293 accepting the request and returning an operation response with one 294 of the successful status codes, the Printer adds the 295 'document-access- error' value to the job's 'job-state-reasons' 296 attribute and MAY populate the job's 'job-document-access-errors' 297 Job Description attribute (see section 4.3.11). See The 298 Implementer's Guide [IPP- IIG] for suggested additional checks. 299 300 If the Printer object supports this operation, it MUST support the 301 'reference-uri-schemes-supported' Printer attribute (see section 4.4.27). 302 303 It is up to the IPP object to interpret the URI and subsequently 304 'pull' the document from the source referenced by the URI string.""" 270 305 raise ipp.errors.ServerErrorOperationNotSupported 271 306 … … 364 399 @handler_for(ipp.OperationCodes.PAUSE_PRINTER) 365 400 def pause_printer(self, request, response): 401 """ 402 3.2.7 Pause-Printer Operation 403 404 This OPTIONAL operation allows a client to stop the Printer object 405 from scheduling jobs on all its devices. Depending on 406 implementation, the Pause-Printer operation MAY also stop the Printer 407 from processing the current job or jobs. Any job that is currently 408 being printed is either stopped as soon as the implementation permits 409 or is completed, depending on implementation. The Printer object 410 MUST still accept create operations to create new jobs, but MUST 411 prevent any jobs from entering the 'processing' state. 412 413 If the Pause-Printer operation is supported, then the Resume-Printer 414 operation MUST be supported, and vice-versa. 415 416 The IPP Printer stops the current job(s) on its device(s) that were 417 in the 'processing' or 'processing-stopped' states as soon as the 418 implementation permits. If the implementation will take appreciable 419 time to stop, the IPP Printer adds the 'moving-to-paused' value to 420 the Printer object's 'printer-state-reasons' attribute (see section 421 4.4.12). When the device(s) have all stopped, the IPP Printer 422 transitions the Printer object to the 'stopped' state, removes the 423 'moving-to-paused' value, if present, and adds the 'paused' value to 424 the Printer object's 'printer-state-reasons' attribute. 425 426 When the current job(s) complete that were in the 'processing' state, 427 the IPP Printer transitions them to the 'completed' state. When the 428 current job(s) stop in mid processing that were in the 'processing' 429 state, the IPP Printer transitions them to the 'processing-stopped' 430 state and adds the 'printer-stopped' value to the job's 'job-state- 431 reasons' attribute. 432 433 For any jobs that are 'pending' or 'pending-held', the 'printer- 434 stopped' value of the jobs' 'job-state-reasons' attribute also 435 applies. However, the IPP Printer NEED NOT update those jobs' 'job- 436 state-reasons' attributes and only need return the 'printer-stopped' 437 value when those jobs are queried (so-called 'lazy evaluation'). 438 439 Whether the Pause-Printer operation affects jobs that were submitted 440 to the device from other sources than the IPP Printer object in the 441 same way that the Pause-Printer operation affects jobs that were 442 submitted to the IPP Printer object using IPP, depends on 443 implementation, i.e., on whether the IPP protocol is being used as a 444 universal management protocol or just to manage IPP jobs, 445 respectively. 446 447 The IPP Printer MUST accept the request in any state and transition 448 the Printer to the indicated new 'printer-state' before returning as 449 follows: 450 451 Current New 'printer IPP Printer's response status 452 'printer- 'printer- -state- code and action: 453 state' state' reasons' 454 455 'idle' 'stopped' 'paused' 'successful-ok' 456 'processing' 'processing' 'moving- OPTION 1: 'successful-ok'; 457 to- Later, when all output has 458 paused' stopped, the 'printer-state' 459 becomes 'stopped', and the 460 'paused' value replaces the 461 'moving-to-paused' value in the 462 'printer-state-reasons' 463 attribute 464 'processing' 'stopped' 'paused' OPTION 2: 'successful-ok'; 465 all device output stopped 466 immediately 467 'stopped' 'stopped' 'paused' 'successful-ok' 468 469 Access Rights: The authenticated user (see section 8.3) performing 470 this operation must be an operator or administrator of the Printer 471 object (see Sections 1 and 8.5). Otherwise, the IPP Printer MUST 472 reject the operation and return: 'client-error-forbidden', 'client- 473 error-not-authenticated', or 'client-error-not-authorized' as 474 appropriate. 475 476 3.2.7.1 Pause-Printer Request 477 478 The following groups of attributes are part of the Pause-Printer 479 Request: 480 481 Group 1: Operation Attributes 482 483 Natural Language and Character Set: 484 The 'attributes-charset' and 'attributes-natural-language' 485 attributes as described in section 3.1.4.1. 486 487 Target: 488 The 'printer-uri' (uri) operation attribute which is the target 489 for this operation as described in section 3.1.5. 490 491 Requesting User Name: 492 The 'requesting-user-name' (name(MAX)) attribute SHOULD be 493 supplied by the client as described in section 8.3. 494 495 3.2.7.2 Pause-Printer Response 496 497 The following groups of attributes are part of the Pause-Printer 498 Response: 499 500 Group 1: Operation Attributes 501 502 Status Message: 503 In addition to the REQUIRED status code returned in every 504 response, the response OPTIONALLY includes a 'status-message' 505 (text(255)) and/or a 'detailed-status-message' (text(MAX)) 506 operation attribute as described in sections 13 and 3.1.6. 507 508 Natural Language and Character Set: 509 The 'attributes-charset' and 'attributes-natural-language' 510 attributes as described in section 3.1.4.2. 511 512 Group 2: Unsupported Attributes 513 514 See section 3.1.7 for details on returning Unsupported Attributes. 515 516 517 """ 366 518 raise ipp.errors.ServerErrorOperationNotSupported 367 519 368 520 @handler_for(ipp.OperationCodes.RESUME_PRINTER) 369 521 def resume_printer(self, request, response): 522 """ 523 3.2.8 Resume-Printer Operation 524 525 This operation allows a client to resume the Printer object 526 scheduling jobs on all its devices. The Printer object MUST remove 527 the 'paused' and 'moving-to-paused' values from the Printer object's 528 'printer-state-reasons' attribute, if present. If there are no other 529 reasons to keep a device paused (such as media-jam), the IPP Printer 530 is free to transition itself to the 'processing' or 'idle' states, 531 depending on whether there are jobs to be processed or not, 532 respectively, and the device(s) resume processing jobs. 533 534 If the Pause-Printer operation is supported, then the Resume-Printer 535 operation MUST be supported, and vice-versa. 536 537 The IPP Printer removes the 'printer-stopped' value from any job's 538 'job-state-reasons' attributes contained in that Printer. 539 540 The IPP Printer MUST accept the request in any state, transition the 541 Printer object to the indicated new state as follows: 542 543 544 Current New 'printer- IPP Printer's response status code and 545 'printer- state' action: 546 state' 547 548 'idle' 'idle' 'successful-ok' 549 'processing' 'processing' 'successful-ok' 550 551 'stopped' 'processing' 'successful-ok'; 552 when there are jobs to be processed 553 'stopped' 'idle' 'successful-ok'; 554 when there are no jobs to be processed. 555 556 Access Rights: The authenticated user (see section 8.3) performing 557 this operation must be an operator or administrator of the Printer 558 object (see Sections 1 and 8.5). Otherwise, the IPP Printer MUST 559 reject the operation and return: 'client-error-forbidden', 'client- 560 error-not-authenticated', or 'client-error-not-authorized' as 561 appropriate. 562 563 The Resume-Printer Request and Resume-Printer Response have the same 564 attribute groups and attributes as the Pause-Printer operation (see 565 sections 3.2.7.1 and 3.2.7.2). 566 """ 370 567 raise ipp.errors.ServerErrorOperationNotSupported 371 568 … … 442 639 @handler_for(ipp.OperationCodes.SET_PRINTER_ATTRIBUTES) 443 640 def set_printer_attributes(self, request, response): 641 444 642 raise ipp.errors.ServerErrorOperationNotSupported 445 643 … … 699 897 @handler_for(ipp.OperationCodes.SEND_URI) 700 898 def send_uri(self, request, response): 701 raise ipp.errors.ServerErrorOperationNotSupported 899 900 """3.2.2 Send URI 901 902 This OPTIONAL operation is identical to the Send-Document 903 operation (see section 3.3.1) except that a client MUST supply 904 a URI reference ('document-uri' operation attribute) rather 905 than the document data itself. If a Printer object supports 906 this operation, clients can use both Send-URI or Send-Document 907 operations to add new documents to an existing multi-document 908 Job object. However, if a client needs to indicate that the 909 previous Send-URI or Send-Document was the last document, the 910 client MUST use the Send-Document operation with no document 911 data and the 'last-document' flag set to 'true' (rather than 912 using a Send-URI operation with no 'document-uri' operation 913 attribute). 914 915 If a Printer object supports this operation, it MUST also 916 support the Print-URI operation (see section 3.2.2). 917 918 The Printer object MUST validate the syntax and URI scheme of 919 the supplied URI before returning a response, just as in the 920 Print-URI operation. The IPP Printer MAY validate the 921 accessibility of the document as part of the operation or 922 subsequently (see section 3.2.2). 923 924 Request 925 ------- 926 927 Group 1: Operation Attributes 928 REQUIRED 'attributes-charset' 929 REQUIRED 'attributes-natural-language' 930 REQUIRED 'job-id' (integer(1:MAX)) and 'printer-uri' (uri) 931 REQUIRED 'document-uri' (uri) 932 OPTIONAL 'job-uri' (uri) 933 OPTIONAL 'requesting-user-name' (name(MAX)) 934 OPTIONAL 'document-name' (name(MAX)) 935 OPTIONAL 'compression' (type3 keyword) 936 OPTIONAL 'document-format' (mimeMediaType) 937 OPTIONAL 'document-natural-language' (naturalLanguage) 938 939 Response 940 -------- 941 942 Group 1: Operation Attributes 943 OPTIONAL 'status-message' (text(255)) 944 OPTIONAL 'detailed-status-message' (text(MAX)) 945 REQUIRED 'attributes-charset' 946 REQUIRED 'attributes-natural-language' 947 Group 2: Unsupported Attributes 948 Group 3: Job Object Attributes 949 REQUIRED 'job-uri' (uri) 950 REQUIRED 'job-id' (integer(1:MAX)) 951 REQUIRED 'job-state' (type1 enum) 952 REQUIRED 'job-state-reasons' (1setOf type2 keyword) 953 OPTIONAL 'job-state-message' (text(MAX)) 954 OPTIONAL 'number-of-intervening-jobs' (integer(0:MAX)) 955 956 """ 957 958 operation = request.attribute_groups[0] 959 960 job_id = None 961 printer_uri = None 962 requesting_user_name = None 963 document_name = None 964 compression = None 965 document_format = None 966 document_natural_language = None 967 last_document = None 968 969 # required attributes 970 if 'job-id' not in operation: 971 raise ipp.errors.ClientErrorBadRequest("Missing 'job-id' attribute") 972 job_id = verify_attribute(operation['job-id'], ipp.JobId)[0] 973 974 if 'last-document' not in operation: 975 raise ipp.errors.ClientErrorBadRequest("Missing 'last-document' attribute") 976 last_document = verify_attribute(operation['last-document'], ipp.LastDocument)[0] 977 978 if 'document-uri' not in operation: 979 raise ipp.errors.ClientErrorBadRequest("Missing 'document-uri' attribute") 980 document_uri = verify_attribute(operation['document-uri'], ipp.DocumentUri)[0] 981 if not last_document: 982 raise ipp.errors.ServerErrorMultipleJobsNotSupported 983 984 # optional attributes 985 if 'printer-uri' in operation: 986 printer_uri = verify_attribute(operation['printer-uri'], ipp.PrinterUri)[0] 987 if printer_uri not in self.printer.uris: 988 raise ipp.errors.ClientErrorAttributes( 989 str(operation['printer-uri']), operation['printer-uri']) 990 991 if 'requesting-user-name' in operation: 992 user_name = verify_attribute( 993 operation['requesting-user-name'], ipp.RequestingUserName)[0] 994 995 if 'document-name' in operation: 996 document_name = verify_attribute( 997 operation['document-name'], ipp.DocumentName)[0] 998 999 if 'compression' in operation: 1000 compression = verify_attribute( 1001 operation['compression'], ipp.Compression)[0] 1002 1003 if 'document-format' in operation: 1004 document_format = verify_attribute( 1005 operation['document-format'], ipp.DocumentFormat)[0] 1006 1007 if 'document-natural-language' in operation: 1008 document_natural_language = verify_attribute( 1009 operation['document_natural_language'], 1010 ipp.DocumentNaturalLanguage)[0] 1011 1012 try: 1013 self.printer.send_uri( 1014 job_id, 1015 document_uri, 1016 document_name=document_name, 1017 document_format=document_format, 1018 document_natural_language=document_natural_language, 1019 requesting_user_name=user_name, 1020 compression=compression, 1021 last_document=last_document) 1022 attrs = self.printer.get_job_attributes(job_id) 1023 except InvalidJobException: 1024 raise ipp.errors.ClientErrorNotFound("bad job: %d" % job_id) 1025 1026 response.attribute_groups.append(ipp.AttributeGroup( 1027 ipp.AttributeTags.JOB, attrs)) 702 1028 703 1029 @handler_for(ipp.OperationCodes.GET_JOB_ATTRIBUTES) … … 807 1133 @handler_for(ipp.OperationCodes.SET_JOB_ATTRIBUTES) 808 1134 def set_job_attributes(self, request, response): 1135 809 1136 raise ipp.errors.ServerErrorOperationNotSupported 810 1137 -
.gitignore
r01e3017 rd17381b 3 3 debian/ 4 4 *.pyc 5 *.log 6 *.log.* 7 tags -
server/lib/gutenbach/server/__init__.py
ra9eb577e rcf0d7e8 3 3 __all__ = ['errors'] 4 4 __all__.extend(errors.__all__) 5 6 def sync(func): 7 """Lock decorator 8 9 Holds a lock (self.lock) for the durration of a method call. 10 """ 11 12 def do(self, *args, **kwargs): 13 with self.lock: 14 return func(self, *args, **kwargs) 15 16 return do 17 __all__.append('sync') 18 5 19 6 20 from job import GutenbachJob -
server/lib/gutenbach/server/player.py
ra9eb577e rcf0d7e8 3 3 import subprocess 4 4 import time 5 from . import sync 5 6 6 7 # initialize logger … … 24 25 25 26 @property 27 @sync 26 28 def is_playing(self): 27 with self.lock: 28 if self._dryrun: 29 playing = self.isAlive() and not self.is_done 30 else: 31 playing = self.isAlive() and \ 32 not self.is_done and \ 33 self.player is not None and \ 34 self.player.poll() is None 35 return playing 29 if self._dryrun: 30 return self.isAlive() and not self.is_done 31 else: 32 return self.isAlive() and \ 33 not self.is_done and \ 34 self.player is not None and \ 35 self.player.poll() is None 36 36 37 37 @property 38 @sync 38 39 def is_paused(self): 39 with self.lock: 40 paused = self.is_playing and self._paused 41 return paused 40 return self.is_playing and self._paused 42 41 43 42 @property … … 49 48 return self._callback 50 49 @callback.setter 50 @sync 51 51 def callback(self, val): 52 with self.lock: 53 self._callback = val 52 self._callback = val 54 53 55 54 def start(self): … … 112 111 113 112 def mplayer_pause(self): 113 # Note: Inner lock due to sleep. 114 114 with self.lock: 115 115 if self.is_playing: … … 123 123 124 124 def mplayer_stop(self): 125 # Note: Inner Lock due to join. 125 126 with self.lock: 126 127 if self.is_playing:
Note: See TracChangeset
for help on using the changeset viewer.