Ignore:
Timestamp:
Jan 21, 2012, 4:36:37 PM (12 years ago)
Author:
Steven Allen <steven@…>
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)
Message:

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

File:
1 edited

Legend:

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

    rfa3e2c6 r9225351  
    184184    def printer_uri_supported(self):
    185185        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")
    186189
    187190    @property
    188191    def uri_authentication_supported(self):
    189192        return ipp.UriAuthenticationSupported("none")
     193    @uri_authentication_supported.setter
     194    def uri_authentication_supported(self, val):
     195        raise ipp.errors.AttributesNotSettable("uri-authentication-supported")
    190196
    191197    @property
    192198    def uri_security_supported(self):
    193199        return ipp.UriSecuritySupported("none")
     200    @uri_security_supported.setter
     201    def uri_security_supported(self, val):
     202        raise ipp.errors.AttributesNotSettable("uri-security-supported")
    194203
    195204    @property
    196205    def printer_name(self):
    197206        return ipp.PrinterName(self.name)
     207    @printer_name.setter
     208    def printer_name(self, val):
     209        raise ipp.errors.AttributesNotSettable("printer-name")
    198210
    199211    @property
    200212    def printer_state(self):
    201213        return ipp.PrinterState(self.state)
     214    @printer_state.setter
     215    def printer_state(self, val):
     216        raise ipp.errors.AttributesNotSettable("printer-state")
    202217
    203218    @property
    204219    def printer_state_reasons(self):
    205220        return ipp.PrinterStateReasons("none")
     221    @printer_state_reasons.setter
     222    def printer_state_reasons(self, val):
     223        raise ipp.errors.AttributesNotSettable("printer-state-reasons")
    206224
    207225    @property
    208226    def ipp_versions_supported(self):
    209227        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")
    210231
    211232    # XXX: We should query ourself for the supported operations
     
    213234    def operations_supported(self):
    214235        return ipp.OperationsSupported(ipp.OperationCodes.GET_JOBS)
     236    @operations_supported.setter
     237    def operations_supported(self, val):
     238        raise ipp.errors.AttributesNotSettable("operations-supported")
    215239
    216240    @property
    217241    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       
    220247    @property
    221248    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")
    223253
    224254    @property
    225255    def natural_language_configured(self):
    226256        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")
    227260
    228261    @property
    229262    def generated_natural_language_supported(self):
    230263        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")
    231267
    232268    @property
    233269    def document_format_default(self):
    234270        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")
    235274
    236275    @property
    237276    def document_format_supported(self):
    238277        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")
    239281
    240282    @property
    241283    def printer_is_accepting_jobs(self):
    242284        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")
    243288
    244289    @property
    245290    def queued_job_count(self):
    246291        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")
    247295
    248296    @property
    249297    def pdl_override_supported(self):
    250298        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")
    251302
    252303    @property
    253304    def printer_up_time(self):
    254305        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")
    255309
    256310    @property
    257311    def compression_supported(self):
    258312        return ipp.CompressionSupported("none")
     313    @compression_supported.setter
     314    def compression_supported(self, val):
     315        raise ipp.errors.AttributesNotSettable("compression-supported")
    259316
    260317    @property
    261318    def multiple_operation_time_out(self):
    262319        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")
    263323
    264324    @property
    265325    def multiple_document_jobs_supported(self):
    266326        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")
    267330
    268331    ######################################################################
     
    389452        return attributes
    390453
    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
    393460
    394461    def cancel_job(self, job_id, requesting_user_name=None):
     
    408475        job.spool(document)
    409476
    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)
    412485
    413486    def get_job_attributes(self, job_id, requested_attributes=None):
     
    422495        return attributes
    423496
    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
Note: See TracChangeset for help on using the changeset viewer.