Changeset 8de3c81 for server


Ignore:
Timestamp:
Jan 21, 2012, 3:19:37 PM (12 years ago)
Author:
Daniel Cooper <danny@…>
Branches:
no-cups
Children:
5141ed8
Parents:
8d89b3d (diff), 7c8a2f8 (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:
Daniel Cooper <danny@…> (01/21/12 15:19:37)
git-committer:
Daniel Cooper <danny@…> (01/21/12 15:19:37)
Message:

Merge branch 'no-cups' of github.com:jhamrick/gutenbach into no-cups

Conflicts:

server/lib/gutenbach/server/requests.py

Location:
server/lib
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • server/lib/TODO

    r20f7360 rc1cebbc  
    2121     [ ] send uri
    2222     [ ] set job attributes
    23      [ ] restart job
    24      [ ] promote job
     23     [X] restart job
     24     [\] promote job
    2525
    2626- add support in job.py for:
  • server/lib/gutenbach/server/job.py

    rb8c3505 rc1cebbc  
    369369
    370370    def restart(self):
    371         # XXX: Todo
    372         pass
     371        """Non-blocking restart.  Job must be finished (see
     372        'GutenbachJob.is_done'), and will be ready to be played (see
     373        'GutenbachJob.is_ready') if this method is successful.
     374
     375        Raises
     376        ------
     377        InvalidJobStateException
     378            If the job is not done.
     379
     380        """
     381
     382        if not self.is_done:
     383            raise errors.InvalidJobStateException(self.state)
     384
     385        logger.debug("restarting job %d" % (self.id, self.document))
     386
     387        self._why_done = None
     388        self.spool(self.document)
  • server/lib/gutenbach/server/printer.py

    r609a9b0 rc1cebbc  
    402402        pass
    403403
    404     def restart_job(self):
    405         pass
    406 
    407     def promote_job(self):
    408         pass
     404    def restart_job(self, job_id, requesting_user_name=None):
     405        job = self.get_job(job_id)
     406        try:
     407            job.restart()
     408        except InvalidJobStateException:
     409            # XXX
     410            raise ipp.errors.ClientErrorNotPossible
     411
     412        with self.lock:
     413            self.finished_jobs.remove(job_id)
     414            self.pending_jobs.append(job_id)
     415
     416    def promote_job(self, job_id, requesting_user_name=None):
     417        # According to RFC 3998, we need to put the job at the front
     418        # of the queue (so that when the currently playing job
     419        # completes, this one will go next
     420       
     421        job = self.get_job(job_id)
     422        job.priority = 1 # XXX we need to actually do something
     423                         # correct here
  • server/lib/gutenbach/server/requests.py

    r8d89b3d r8de3c81  
    896896    @handler_for(ipp.OperationCodes.SEND_URI)
    897897    def send_uri(self, request, response):
     898<<<<<<< HEAD
    898899       raise ipp.errors.ServerErrorOperationNotSupported
     900=======
     901        """3.2.2 Send URI
     902
     903        This OPTIONAL operation is identical to the Send-Document
     904        operation (see section 3.3.1) except that a client MUST supply
     905        a URI reference ('document-uri' operation attribute) rather
     906        than the document data itself.  If a Printer object supports
     907        this operation, clients can use both Send-URI or Send-Document
     908        operations to add new documents to an existing multi-document
     909        Job object.  However, if a client needs to indicate that the
     910        previous Send-URI or Send-Document was the last document, the
     911        client MUST use the Send-Document operation with no document
     912        data and the 'last-document' flag set to 'true' (rather than
     913        using a Send-URI operation with no 'document-uri' operation
     914        attribute).
     915
     916        If a Printer object supports this operation, it MUST also
     917        support the Print-URI operation (see section 3.2.2).
     918
     919        The Printer object MUST validate the syntax and URI scheme of
     920        the supplied URI before returning a response, just as in the
     921        Print-URI operation.  The IPP Printer MAY validate the
     922        accessibility of the document as part of the operation or
     923        subsequently (see section 3.2.2).
     924
     925        Request
     926        -------
     927
     928        Group 1: Operation Attributes
     929            REQUIRED 'attributes-charset'
     930            REQUIRED 'attributes-natural-language'
     931            REQUIRED 'job-id' (integer(1:MAX)) and 'printer-uri' (uri)
     932            REQUIRED 'document-uri' (uri)
     933              -or-   'job-uri' (uri)
     934            OPTIONAL 'requesting-user-name' (name(MAX))
     935            OPTIONAL 'document-name' (name(MAX))
     936            OPTIONAL 'compression' (type3 keyword)
     937            OPTIONAL 'document-format' (mimeMediaType)
     938            OPTIONAL 'document-natural-language' (naturalLanguage)
     939        Group 2: Document Content
     940           
     941        Response
     942        --------
     943
     944        Group 1: Operation Attributes
     945            OPTIONAL 'status-message' (text(255))
     946            OPTIONAL 'detailed-status-message' (text(MAX))
     947            REQUIRED 'attributes-charset'
     948            REQUIRED 'attributes-natural-language'
     949        Group 2: Unsupported Attributes
     950        Group 3: Job Object Attributes
     951            REQUIRED 'job-uri' (uri)
     952            REQUIRED 'job-id' (integer(1:MAX))
     953            REQUIRED 'job-state' (type1 enum)
     954            REQUIRED 'job-state-reasons' (1setOf type2 keyword)
     955            OPTIONAL 'job-state-message' (text(MAX))
     956            OPTIONAL 'number-of-intervening-jobs' (integer(0:MAX))
     957
     958        """
     959       
     960        operation = request.attribute_groups[0]
     961
     962        job_id = None
     963        printer_uri = None
     964        requesting_user_name = None
     965        document_name = None
     966        compression = None
     967        document_format = None
     968        document_natural_language = None
     969        last_document = None
     970
     971        # required attributes
     972        if 'job-id' not in operation:
     973            raise ipp.errors.ClientErrorBadRequest("Missing 'job-id' attribute")
     974        job_id = verify_attribute(operation['job-id'], ipp.JobId)[0]
     975
     976        if 'last-document' not in operation:
     977            raise ipp.errors.ClientErrorBadRequest("Missing 'last-document' attribute")
     978        last_document = verify_attribute(operation['last-document'], ipp.LastDocument)[0]
     979
     980        if 'document-uri' not in operation:
     981            raise ipp.errors.ClientErrorBadRequest("Missing 'document-uri' attribute")
     982        document_uri = verify_attribute(operation['document-uri'], ipp.DocumentUri)[0]
     983        if not last_document:
     984            raise ipp.errors.ServerErrorMultipleJobsNotSupported
     985
     986        # optional attributes
     987        if 'printer-uri' in operation:
     988            printer_uri = verify_attribute(operation['printer-uri'], ipp.PrinterUri)[0]
     989            if printer_uri not in self.printer.uris:
     990                raise ipp.errors.ClientErrorAttributes(
     991                    str(operation['printer-uri']), operation['printer-uri'])
     992
     993        if 'requesting-user-name' in operation:
     994            user_name = verify_attribute(
     995                operation['requesting-user-name'], ipp.RequestingUserName)[0]
     996
     997        if 'document-name' in operation:
     998            document_name = verify_attribute(
     999                operation['document-name'], ipp.DocumentName)[0]
     1000
     1001        if 'compression' in operation:
     1002            compression = verify_attribute(
     1003                operation['compression'], ipp.Compression)[0]
     1004
     1005        if 'document-format' in operation:
     1006            document_format = verify_attribute(
     1007                operation['document-format'], ipp.DocumentFormat)[0]
     1008
     1009        if 'document-natural-language' in operation:
     1010            document_natural_language = verify_attribute(
     1011                operation['document_natural_language'],
     1012                ipp.DocumentNaturalLanguage)[0]
     1013
     1014        try:
     1015            self.printer.send_uri(
     1016                job_id,
     1017                document_uri=document_uri,
     1018                document_name=document_name,
     1019                document_format=document_format,
     1020                document_natural_language=document_natural_language,
     1021                requesting_user_name=user_name,
     1022                compression=compression,
     1023                last_document=last_document)
     1024            attrs = self.printer.get_job_attributes(job_id)
     1025        except InvalidJobException:
     1026            raise ipp.errors.ClientErrorNotFound("bad job: %d" % job_id)
     1027
     1028        response.attribute_groups.append(ipp.AttributeGroup(
     1029            ipp.AttributeTags.JOB, attrs))
     1030>>>>>>> 7c8a2f82df069878680146d8ac18339ec96bd487
    8991031
    9001032    @handler_for(ipp.OperationCodes.GET_JOB_ATTRIBUTES)
Note: See TracChangeset for help on using the changeset viewer.