Changeset 5d24a81


Ignore:
Timestamp:
Mar 14, 2011, 11:28:58 PM (13 years ago)
Author:
Jessica B. Hamrick <jhamrick@…>
Branches:
no-cups
Children:
5c5fe6d
Parents:
1a98666
git-author:
Jessica B. Hamrick <jhamrick@…> (03/14/11 23:28:58)
git-committer:
Jessica B. Hamrick <jhamrick@…> (03/14/11 23:28:58)
Message:

Fix bugs in Job and Printer

Location:
server/lib/gutenbach/server
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • server/lib/gutenbach/server/job.py

    rdf51061 r5d24a81  
    5555            "Please use enqueue().")
    5656
    57     def enqueue(self, printer):
     57    def enqueue(self, printer, jobid):
    5858        if self.status != 'initializing':
    5959            raise InvalidJobException(
     
    6161                "already been initialized!")
    6262        self._printer = printer
     63        self._jobid = jobid
    6364        self._status = 'active'
    6465
     
    7071        self._status = 'playing'
    7172        # TODO: add external call to music player
     73        print "Playing job %s" % str(self)
    7274        self.printer.complete_job(self.jobid)
    7375
    74     def finished(self):
     76    def finish(self):
    7577        self._status = 'finished'
    7678
     
    7981
    8082    def __str__(self):
    81         return "<Job %d>" % self.jobid
     83        return "<Job %d '%s'>" % \
     84               (self.jobid if self.jobid is not None else -1, \
     85                                  self.document)
  • server/lib/gutenbach/server/printer.py

    r1a98666 r5d24a81  
    2525        self.jobs = {}
    2626
    27         self._next_jobid = -1
     27        self._next_jobid = 0
    2828
    2929    @property
     
    4040        self.active_jobs.append(jobid)
    4141        self.jobs[jobid] = job
    42         job.jobid = jobid
    43         job.enqueue(self)
     42        job.enqueue(self, jobid)
    4443        return jobid
    4544
    4645    def complete_job(self, jobid):
    47         job = self.active_jobs.pop(0)
     46        job = self.jobs[self.active_jobs.pop(0)]
    4847        if job.jobid != jobid:
    4948            raise InvalidJobException(
     
    5655
    5756    def start_job(self, jobid):
    58         job = self.active_jobs[0]
     57        job = self.jobs[self.active_jobs[0]]
    5958        if job.jobid != jobid:
    6059            raise InvalidJobException(
Note: See TracChangeset for help on using the changeset viewer.