Changes in / [279640c:f70792f]
- Location:
- server/lib
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
server/lib/TODO
rf0807b8 r374c558 69 69 [ ] http://gutenbach.mit.edu/ticket/41 70 70 [ ] http://gutenbach.mit.edu/ticket/18 71 72 === CONSIDERATIONS FOR MPD ===73 74 We are considering using MPD (the Music Player Daemon) for playback, instead75 of mplayer. This gives us a pony (gapless playback), and makes some other76 things, like keeping track of the queue, much easier. There is a lot of work77 needed to make this work, though.78 79 THIS ADDS A DEPENDENCY: python-mpd80 81 We will have to re-implement all the functions in jobs.py, and completely82 re-structure player.py83 84 If we want video playback eventually (and we do), there will be some hackery85 involved. We will pause mpd playback, do the video playback completely86 separately, and then resume mpd playback.87 88 Some almost-pseudocode:89 90 startup:91 client = MPDClient()92 client.connect(**{'host':'/var/run/mpd/socket', 'port':'6600'})93 94 adding a song to the queue:95 Receive job96 Put it into a file [gutenbach/FILENAME]97 Tell MPD to add it to the queue [client.addid('gutenbach/FILENAME')]98 Find out what the id is99 Store all the data [including the temporary filename]100 IF WE ARE SUPPOSED TO BE PLAYING, MAKE SURE WE *ARE* PLAYING101 In particular, if the queue was empty, start playback [gutenbach.play()]102 103 when a job completes playing:104 Remove the file [rm gutenbach/FILENAME]105 106 getting the queue:107 get playlist, parse return [client.playlistid()]108 109 removing a job:110 dequeue it [client.deleteid('NUMBER')]111 remove the file112 tell them what you did113 114 restart song:115 client.seek(0,1) [0% through song 1...]116 -
server/lib/gutenbach/server/job.py
r57bc2dc r9225351 53 53 """ 54 54 return cmp(self.priority, other.priority) 55 56 def __del__(self):57 if self.player:58 self.player.mplayer_stop()59 self.player = None60 if self.document and not self.document.closed:61 self.document.close()62 self.document = None63 64 self.id = None65 self.creator = None66 self.name = None67 self.priority = None68 self._why_done = None69 55 70 56 ###################################################################### … … 273 259 if not hasattr(document, "close"): 274 260 raise errors.InvalidDocument, "no close attribute" 275 if not hasattr(document, "closed"):276 raise errors.InvalidDocument, "no closed attribute"277 261 278 262 def spool(self, document=None): -
server/lib/gutenbach/server/printer.py
r57bc2dc r9225351 9 9 import traceback 10 10 import sys 11 import tempfile12 11 from . import sync 13 12 … … 362 361 ###################################################################### 363 362 364 def print_job(self, document, document_name=None, document_format=None, 365 document_natural_language=None, requesting_user_name=None, 366 compression=None, job_name=None, job_k_octets=None): 367 368 # create the job 369 job_id = self.create_job( 370 requesting_user_name=requesting_user_name, 371 job_name=job_name, 372 job_k_octets=job_k_octets) 373 374 # send the document 375 self.send_document( 376 job_id, 377 document, 378 document_name=document_name, 379 document_format=document_format, 380 document_natural_language=document_natural_language, 381 requesting_user_name=requesting_user_name, 382 compression=compression, 383 last_document=False) 384 385 return job_id 386 387 def verify_job(self, document_name=None, document_format=None, 388 document_natural_language=None, requesting_user_name=None, 389 compression=None, job_name=None, job_k_octets=None): 390 391 job_id = self._next_job_id 392 job = GutenbachJob( 393 job_id, 394 creator=requesting_user_name, 395 name=job_name) 396 job.spool(tempfile.TemporaryFile()) 397 job.abort() 398 del job 363 def print_job(self): 364 pass 365 366 def validate_job(self): 367 pass 399 368 400 369 def get_jobs(self, requesting_user_name=None, which_jobs=None, … … 428 397 pass 429 398 430 def create_job(self, requesting_user_name=None, job_name=None, 431 job_k_octets=None): 432 399 def create_job(self, requesting_user_name=None, job_name=None, job_k_octets=None): 433 400 job_id = self._next_job_id 434 401 self._next_job_id += 1 … … 438 405 creator=requesting_user_name, 439 406 name=job_name) 440 407 441 408 self.jobs[job_id] = job 442 409 self.pending_jobs.append(job_id) … … 458 425 self.paused = True 459 426 427 428 460 429 @sync 461 430 def resume_printer(self): … … 472 441 self.paused = False 473 442 474 @sync475 443 def get_printer_attributes(self, requested_attributes=None): 476 444 if requested_attributes is None: … … 484 452 return attributes 485 453 486 @sync487 454 def set_printer_attributes(self, job_id, attributes): 488 455 for attr in attributes: … … 492 459 raise ipp.errors.ClientErrorAttributes 493 460 494 @sync495 461 def cancel_job(self, job_id, requesting_user_name=None): 496 462 job = self.get_job(job_id) … … 501 467 raise 502 468 503 @sync504 469 def send_document(self, job_id, document, document_name=None, 505 470 document_format=None, document_natural_language=None, … … 510 475 job.spool(document) 511 476 512 @sync513 477 def send_uri(self, job_id, document_uri, document_name=None, 514 478 document_format=None, document_natural_language=None, … … 520 484 #job.spool_uri(document_uri) 521 485 522 @sync523 486 def get_job_attributes(self, job_id, requested_attributes=None): 524 487 if requested_attributes is None: … … 532 495 return attributes 533 496 534 @sync535 497 def set_job_attributes(self, job_id, attributes): 536 498 job = self.get_job(job_id) … … 542 504 elif attr == "job-originating-user-name": 543 505 job.creator = attributes[attr] # XXX: do we want this? 544 545 @sync 506 546 507 def restart_job(self, job_id, requesting_user_name=None): 547 508 job = self.get_job(job_id) … … 552 513 raise ipp.errors.ClientErrorNotPossible 553 514 554 self.finished_jobs.remove(job_id)555 self.pending_jobs.append(job_id)556 557 @sync 515 with self.lock: 516 self.finished_jobs.remove(job_id) 517 self.pending_jobs.append(job_id) 518 558 519 def promote_job(self, job_id, requesting_user_name=None): 559 520 # According to RFC 3998, we need to put the job at the front
Note: See TracChangeset
for help on using the changeset viewer.