Ignore:
Timestamp:
Dec 23, 2011, 8:20:29 PM (12 years ago)
Author:
Jessica B. Hamrick <jhamrick@…>
Branches:
no-cups
Children:
b828a96
Parents:
f6e2532
git-author:
Jessica B. Hamrick <jhamrick@…> (12/23/11 20:20:29)
git-committer:
Jessica B. Hamrick <jhamrick@…> (12/23/11 20:20:29)
Message:

Checkpoint, creating classes for specific IPP attributes

File:
1 edited

Legend:

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

    rf6e2532 raded2d1  
    44import gutenbach.ipp as ipp
    55import gutenbach.ipp.constants as const
     6import gutenbach.ipp.object_attributes.printer_description_attributes as pda
    67import logging
    78import time
     
    8889    @property
    8990    def printer_uri_supported(self):
    90         return self.uri
     91        return pda.PrinterUriSupported(self.uri)
    9192
    9293    @property
    9394    def uri_authentication_supported(self):
    94         return "none"
     95        return pda.UriAuthenticationSupported("none")
    9596
    9697    @property
    9798    def uri_security_supported(self):
    98         return "none"
     99        return pda.UriSecuritySupported("none")
    99100
    100101    @property
    101102    def printer_name(self):
    102         return self.name
     103        return pda.PrinterName(self.name)
    103104
    104105    @property
    105106    def printer_state(self):
    106         return 3 # idle
     107        return pda.PrinterState(ipp.constants.PrinterStates.IDLE)
    107108
    108109    @property
    109110    def printer_state_reasons(self):
    110         return "none"
     111        return pda.PrinterStateReasons("none")
    111112
    112113    @property
    113114    def ipp_versions_supported(self):
    114         return ("1.0", "1.1")
     115        return pda.IppVersionsSupported("1.0", "1.1")
    115116
    116117    # XXX: We should query ourself for the supported operations
    117118    @property
    118119    def operations_supported(self):
    119         return ipp.Operations.GET_JOBS # get-jobs
     120        return pda.OperationsSupported(ipp.Operations.GET_JOBS)
    120121
    121122    @property
    122123    def charset_configured(self):
    123         return "utf-8"
     124        return pda.CharsetConfigured("utf-8")
    124125
    125126    @property
    126127    def charset_supported(self):
    127         return "utf-8"
     128        return pda.CharsetSupported("utf-8")
    128129
    129130    @property
    130131    def natural_language_configured(self):
    131         return "en-us"
     132        return pda.NaturalLanguageConfigured("en-us")
    132133
    133134    @property
    134135    def generated_natural_language_supported(self):
    135         return "en-us"
     136        return pda.GeneratedNaturalLanguageSupported("en-us")
    136137
    137138    @property
    138139    def document_format_default(self):
    139         return "application/octet-stream"
     140        return pda.DocumentFormatDefault("application/octet-stream")
    140141
    141142    @property
    142143    def document_format_supported(self):
    143         return ("application/octet-stream", "audio/mp3")
     144        return pda.DocumentFormatSupported("application/octet-stream", "audio/mp3")
    144145
    145146    @property
    146147    def printer_is_accepting_jobs(self):
    147         return True
     148        return pda.PrinterIsAcceptingJobs(True)
    148149
    149150    @property
    150151    def queued_job_count(self):
    151         return len(self.active_jobs)
     152        return pda.QueuedJobCount(len(self.active_jobs))
    152153
    153154    @property
    154155    def pdl_override_supported(self):
    155         return "not-attempted"
     156        return pda.PdlOverrideSupported("not-attempted")
    156157
    157158    @property
    158159    def printer_up_time(self):
    159         return int(time.time()) - self.time_created
     160        return pda.PrinterUpTime(int(time.time()) - self.time_created)
    160161
    161162    @property
    162163    def compression_supported(self):
    163         return "none"
     164        return pda.CompressionSupported("none")
    164165
    165166    @property
    166167    def multiple_operation_time_out(self):
    167         return 240
     168        return pda.MultipleOperationTimeOut(240)
    168169
    169170    @property
    170171    def multiple_document_jobs_supported(self):
    171         return False
     172        return pda.MultipleDocumentJobsSupported(False)
    172173
    173174    def get_printer_attributes(self, request):
    174         attributes = [(attr, getattr(self, attr)) for attr in self.attributes]
    175         attributes = map(lambda x: x if isinstance(x[1], (tuple, list)) else (x[0], [x[1]]),
    176                          attributes)
     175        attributes = [getattr(self, attr) for attr in self.attributes]
    177176        return attributes
    178177
Note: See TracChangeset for help on using the changeset viewer.