Changeset 1a63bf7 for server/lib/gutenbach/server/printer.py
- Timestamp:
- Dec 20, 2011, 11:17:58 AM (12 years ago)
- Branches:
- no-cups
- Children:
- 08a764a
- Parents:
- 6ed9d7a
- git-author:
- Jessica B. Hamrick <jhamrick@…> (12/20/11 11:17:58)
- git-committer:
- Jessica B. Hamrick <jhamrick@…> (12/20/11 11:17:58)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
server/lib/gutenbach/server/printer.py
rb2e077a r1a63bf7 12 12 class GutenbachPrinter(object): 13 13 14 # for IPP 14 15 attributes = [ 15 16 "printer-uri-supported", … … 31 32 "pdl-override-supported", 32 33 "printer-up-time", 33 "compression-supported"] 34 "compression-supported" 35 ] 34 36 35 37 #def __init__(self, name, card, mixer): 36 38 def __init__(self, name): 37 39 38 self._name = name 39 self._uri = "ipp://localhost:8000/printers/" + self._name 40 self._time_created = int(time.time()) 40 self.name = name 41 self.uri = "ipp://localhost:8000/printers/" + self.name 42 self.time_created = int(time.time()) 43 self.state = "idle" 41 44 42 45 # if card >= len(aa.cards()): … … 56 59 self._next_jobid = 0 57 60 61 def __getattr__(self, attr): 62 try: 63 return super(Printer, self).__getattr__(attr) 64 except AttributeError: 65 pass 66 67 return super(Printer, self).__getattr__( 68 attr.replace("-", "_")) 69 70 def __hasattr__(self, attr): 71 has = super(Printer, self).__hasattr__(attr) 72 if not has: 73 has = super(Printer, self).__hasattr__( 74 attr.replace("-", "_")) 75 return has 76 58 77 ## Printer attributes 78 59 79 @property 60 80 def printer_uri_supported(self): 61 return ipp.Attribute( 62 "printer-uri-supported", 63 [ipp.Value(ipp.Tags.URI, self._uri)]) 64 81 return self.uri 82 65 83 @property 66 84 def uri_authentication_supported(self): 67 return ipp.Attribute( 68 "uri-authentication-supported", 69 [ipp.Value(ipp.Tags.KEYWORD, "none")]) 85 return "none" 70 86 71 87 @property 72 88 def uri_security_supported(self): 73 return ipp.Attribute( 74 "uri-security-supported", 75 [ipp.Value(ipp.Tags.KEYWORD, "none")]) 89 return "none" 76 90 77 91 @property 78 92 def printer_name(self): 79 return ipp.Attribute( 80 "printer-name", 81 [ipp.Value(ipp.Tags.NAME_WITHOUT_LANGUAGE, self._name)]) 82 93 return self.name 94 83 95 @property 84 96 def printer_state(self): 85 return ipp.Attribute( 86 "printer-state", 87 [ipp.Value(ipp.Tags.ENUM, const.PrinterStates.IDLE)]) 88 97 return self.state 98 89 99 @property 90 100 def printer_state_reasons(self): 91 return ipp.Attribute( 92 "printer-state-reasons", 93 [ipp.Value(ipp.Tags.KEYWORD, "none")]) 101 return "none" 94 102 95 103 @property 96 104 def ipp_versions_supported(self): 97 return ipp.Attribute( 98 "ipp-versions-supported", 99 [ipp.Value(ipp.Tags.KEYWORD, "1.0"), 100 ipp.Value(ipp.Tags.KEYWORD, "1.1")]) 101 105 return ("1.0", "1.1") 102 106 # XXX: We should query ourself for the supported operations 107 103 108 @property 104 109 def operations_supported(self): 105 return ipp.Attribute( 106 "operations-supported", 107 [ipp.Value(ipp.Tags.ENUM, const.Operations.GET_JOBS)]) 110 return "get-jobs" 108 111 109 112 @property 110 113 def charset_configured(self): 111 return ipp.Attribute( 112 "charset-configured", 113 [ipp.Value(ipp.Tags.CHARSET, "utf-8")]) 114 return "utf-8" 114 115 115 116 @property 116 117 def charset_supported(self): 117 return ipp.Attribute( 118 "charset-supported", 119 [ipp.Value(ipp.Tags.CHARSET, "utf-8")]) 118 return "utf-8" 120 119 121 120 @property 122 121 def natural_language_configured(self): 123 return ipp.Attribute( 124 "natural-language-configured", 125 [ipp.Value(ipp.Tags.NATURAL_LANGUAGE, "en-us")]) 122 return "en-us" 126 123 127 124 @property 128 125 def generated_natural_language_supported(self): 129 return ipp.Attribute( 130 "generated-natural-language-supported", 131 [ipp.Value(ipp.Tags.NATURAL_LANGUAGE, "en-us")]) 126 return "en-us" 132 127 133 128 @property 134 129 def document_format_default(self): 135 return ipp.Attribute( 136 "document-format-default", 137 [ipp.Value(ipp.Tags.MIME_MEDIA_TYPE, "application/octet-stream")]) 130 return "application/octet-stream" 138 131 139 132 @property 140 133 def document_format_supported(self): 141 return ipp.Attribute( 142 "document-format-supported", 143 [ipp.Value(ipp.Tags.MIME_MEDIA_TYPE, "application/octet-stream"), 144 ipp.Value(ipp.Tags.MIME_MEDIA_TYPE, "audio/mp3")]) 134 return ("application/octet-stream", "audio/mp3") 145 135 146 136 @property 147 137 def printer_is_accepting_jobs(self): 148 return ipp.Attribute( 149 "printer-is-accepting-jobs", 150 [ipp.Value(ipp.Tags.BOOLEAN, True)]) 138 return True 151 139 152 140 @property 153 141 def queued_job_count(self): 154 return ipp.Attribute( 155 "queued-job-count", 156 [ipp.Value(ipp.Tags.INTEGER, len(self.active_jobs))]) 142 return len(self.active_jobs) 157 143 158 144 @property 159 145 def pdl_override_supported(self): 160 return ipp.Attribute( 161 "pdl-override-supported", 162 [ipp.Value(ipp.Tags.KEYWORD, "not-attempted")]) 146 return "not-attempted" 163 147 164 148 @property 165 149 def printer_up_time(self): 166 return ipp.Attribute( 167 "printer-up-time", 168 [ipp.Value(ipp.Tags.INTEGER, int(time.time()) - self._time_created)]) 150 return int(time.time()) - self.time_created 169 151 170 152 @property 171 153 def compression_supported(self): 172 return ipp.Attribute( 173 "compression-supported", 174 [ipp.Value(ipp.Tags.KEYWORD, "none")]) 154 return "none" 175 155 176 156 def get_printer_attributes(self, request): 177 attributes = [ getattr(self, attr.replace("-", "_")) for attr in self.attributes]157 attributes = [(attr, getattr(self, attr)) for attr in self.attributes] 178 158 return attributes 179 159 … … 229 209 230 210 def __str__(self): 231 return "<Printer '%s'>" % self. _name211 return "<Printer '%s'>" % self.name
Note: See TracChangeset
for help on using the changeset viewer.