Changeset 793432f for server/lib/gutenbach/server
- Timestamp:
- Dec 23, 2011, 9:37:39 PM (12 years ago)
- Branches:
- no-cups
- Children:
- 1037115
- Parents:
- b828a96
- git-author:
- Jessica B. Hamrick <jhamrick@…> (12/23/11 21:37:39)
- git-committer:
- Jessica B. Hamrick <jhamrick@…> (12/23/11 21:37:39)
- Location:
- server/lib/gutenbach/server
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
server/lib/gutenbach/server/job.py
raded2d1 r793432f 1 1 from exceptions import InvalidJobException, InvalidPrinterStateException 2 2 import os 3 import gutenbach.ipp .object_attributes.job_description_attributes as jda3 import gutenbach.ipp as ipp 4 4 5 5 # initialize logger … … 51 51 @property 52 52 def job_id(self): 53 return jda.JobId(self.jid)53 return ipp.JobId(self.jid) 54 54 55 55 @property 56 56 def job_name(self): 57 return jda.JobName(self.name)57 return ipp.JobName(self.name) 58 58 59 59 # XXX: we need to actually calculate this! 60 60 @property 61 61 def job_originating_user_name(self): 62 return jda.JobOriginatingUserName("jhamrick")62 return ipp.JobOriginatingUserName("jhamrick") 63 63 64 64 # XXX: we need to actually calculate this! 65 65 @property 66 66 def job_k_octets(self): 67 return jda.JobKOctets(1)67 return ipp.JobKOctets(1) 68 68 69 69 @property 70 70 def job_state(self): 71 return jda.JobState(self.status)71 return ipp.JobState(self.status) 72 72 73 73 @property 74 74 def job_printer_uri(self): 75 return jda.JobPrinterUri(self.printer.uri)75 return ipp.JobPrinterUri(self.printer.uri) 76 76 77 77 def get_job_attributes(self, request): -
server/lib/gutenbach/server/printer.py
raded2d1 r793432f 1 1 #import alsaaudio as aa 2 2 from .exceptions import InvalidJobException, InvalidPrinterStateException 3 from gutenbach.ipp.attribute import Attribute4 3 import gutenbach.ipp as ipp 5 import gutenbach.ipp.constants as const6 import gutenbach.ipp.object_attributes.printer_description_attributes as pda7 4 import logging 8 5 import time … … 89 86 @property 90 87 def printer_uri_supported(self): 91 return pda.PrinterUriSupported(self.uri)88 return ipp.PrinterUriSupported(self.uri) 92 89 93 90 @property 94 91 def uri_authentication_supported(self): 95 return pda.UriAuthenticationSupported("none")92 return ipp.UriAuthenticationSupported("none") 96 93 97 94 @property 98 95 def uri_security_supported(self): 99 return pda.UriSecuritySupported("none")96 return ipp.UriSecuritySupported("none") 100 97 101 98 @property 102 99 def printer_name(self): 103 return pda.PrinterName(self.name)100 return ipp.PrinterName(self.name) 104 101 105 102 @property 106 103 def printer_state(self): 107 return pda.PrinterState(ipp.constants.PrinterStates.IDLE)104 return ipp.PrinterState(ipp.constants.PrinterStates.IDLE) 108 105 109 106 @property 110 107 def printer_state_reasons(self): 111 return pda.PrinterStateReasons("none")108 return ipp.PrinterStateReasons("none") 112 109 113 110 @property 114 111 def ipp_versions_supported(self): 115 return pda.IppVersionsSupported("1.0", "1.1")112 return ipp.IppVersionsSupported("1.0", "1.1") 116 113 117 114 # XXX: We should query ourself for the supported operations 118 115 @property 119 116 def operations_supported(self): 120 return pda.OperationsSupported(ipp.Operations.GET_JOBS)117 return ipp.OperationsSupported(ipp.OperationCodes.GET_JOBS) 121 118 122 119 @property 123 120 def charset_configured(self): 124 return pda.CharsetConfigured("utf-8")121 return ipp.CharsetConfigured("utf-8") 125 122 126 123 @property 127 124 def charset_supported(self): 128 return pda.CharsetSupported("utf-8")125 return ipp.CharsetSupported("utf-8") 129 126 130 127 @property 131 128 def natural_language_configured(self): 132 return pda.NaturalLanguageConfigured("en-us")129 return ipp.NaturalLanguageConfigured("en-us") 133 130 134 131 @property 135 132 def generated_natural_language_supported(self): 136 return pda.GeneratedNaturalLanguageSupported("en-us")133 return ipp.GeneratedNaturalLanguageSupported("en-us") 137 134 138 135 @property 139 136 def document_format_default(self): 140 return pda.DocumentFormatDefault("application/octet-stream")137 return ipp.DocumentFormatDefault("application/octet-stream") 141 138 142 139 @property 143 140 def document_format_supported(self): 144 return pda.DocumentFormatSupported("application/octet-stream", "audio/mp3")141 return ipp.DocumentFormatSupported("application/octet-stream", "audio/mp3") 145 142 146 143 @property 147 144 def printer_is_accepting_jobs(self): 148 return pda.PrinterIsAcceptingJobs(True)145 return ipp.PrinterIsAcceptingJobs(True) 149 146 150 147 @property 151 148 def queued_job_count(self): 152 return pda.QueuedJobCount(len(self.active_jobs))149 return ipp.QueuedJobCount(len(self.active_jobs)) 153 150 154 151 @property 155 152 def pdl_override_supported(self): 156 return pda.PdlOverrideSupported("not-attempted")153 return ipp.PdlOverrideSupported("not-attempted") 157 154 158 155 @property 159 156 def printer_up_time(self): 160 return pda.PrinterUpTime(int(time.time()) - self.time_created)157 return ipp.PrinterUpTime(int(time.time()) - self.time_created) 161 158 162 159 @property 163 160 def compression_supported(self): 164 return pda.CompressionSupported("none")161 return ipp.CompressionSupported("none") 165 162 166 163 @property 167 164 def multiple_operation_time_out(self): 168 return pda.MultipleOperationTimeOut(240)165 return ipp.MultipleOperationTimeOut(240) 169 166 170 167 @property 171 168 def multiple_document_jobs_supported(self): 172 return pda.MultipleDocumentJobsSupported(False)169 return ipp.MultipleDocumentJobsSupported(False) 173 170 174 171 def get_printer_attributes(self, request): -
server/lib/gutenbach/server/requests.py
rb828a96 r793432f 1 1 from gutenbach.server.printer import GutenbachPrinter 2 2 import gutenbach.ipp as ipp 3 import gutenbach.ipp.constants as consts4 3 import logging 5 4 import traceback … … 54 53 exctype, excval, exctb = sys.exc_info() 55 54 logger.error("%s: %s" % (exctype.__name__, excval.message)) 56 response = ipp.op s.make_empty_response(request)55 response = ipp.operations.make_empty_response(request) 57 56 excval.update_response(response) 58 57 … … 61 60 except Exception: 62 61 logger.error(traceback.format_exc()) 63 response = ipp.op s.make_empty_response(request)62 response = ipp.operations.make_empty_response(request) 64 63 response.operation_id = ipp.StatusCodes.INTERNAL_ERROR 65 64 … … 68 67 def unknown_operation(self, request): 69 68 logger.warning("Received unknown operation 0x%x" % request.operation_id) 70 response = ipp.op s.make_empty_response(request)71 response.operation_id = consts.StatusCodes.OPERATION_NOT_SUPPORTED69 response = ipp.operations.make_empty_response(request) 70 response.operation_id = ipp.StatusCodes.OPERATION_NOT_SUPPORTED 72 71 return response 73 72 74 73 ##### Printer Commands 75 74 76 @handler_for( consts.Operations.PRINT_JOB)75 @handler_for(ipp.OperationCodes.PRINT_JOB) 77 76 def print_job(self, request): 78 77 """RFC 2911: 3.2.1 Print-Job Operation … … 88 87 raise ipp.errors.ServerErrorOperationNotSupported 89 88 90 @handler_for( consts.Operations.VALIDATE_JOB)89 @handler_for(ipp.OperationCodes.VALIDATE_JOB) 91 90 def validate_job(self, request): 92 91 93 92 raise ipp.errors.ServerErrorOperationNotSupported 94 93 95 @handler_for( consts.Operations.GET_JOBS)94 @handler_for(ipp.OperationCodes.GET_JOBS) 96 95 def get_jobs(self, request): 97 96 """RFC 2911: 3.2.6 Get-Jobs Operation … … 110 109 111 110 # verify the request and get an attribute dictionary 112 req_dict = ipp.op s.verify_get_jobs_request(request)111 req_dict = ipp.operations.verify_get_jobs_request(request) 113 112 114 113 # lookup printer name … … 124 123 125 124 # build the response 126 response = ipp.op s.make_get_jobs_response(jobs, request)127 return response 128 129 @handler_for( consts.Operations.PRINT_URI)125 response = ipp.operations.make_get_jobs_response(jobs, request) 126 return response 127 128 @handler_for(ipp.OperationCodes.PRINT_URI) 130 129 def print_uri(self, request): 131 130 raise ipp.errors.ServerErrorOperationNotSupported 132 131 133 @handler_for( consts.Operations.CREATE_JOB)132 @handler_for(ipp.OperationCodes.CREATE_JOB) 134 133 def create_job(self, request): 135 134 """RFC 2911: 3.2.4 Create-Job Operation … … 183 182 raise ipp.errors.ServerErrorOperationNotSupported 184 183 185 @handler_for( consts.Operations.PAUSE_PRINTER)184 @handler_for(ipp.OperationCodes.PAUSE_PRINTER) 186 185 def pause_printer(self, request): 187 186 raise ipp.errors.ServerErrorOperationNotSupported 188 187 189 @handler_for( consts.Operations.RESUME_PRINTER)188 @handler_for(ipp.OperationCodes.RESUME_PRINTER) 190 189 def resume_printer(self, request): 191 190 raise ipp.errors.ServerErrorOperationNotSupported 192 191 193 @handler_for( consts.Operations.GET_PRINTER_ATTRIBUTES)192 @handler_for(ipp.OperationCodes.GET_PRINTER_ATTRIBUTES) 194 193 def get_printer_attributes(self, request): 195 194 """RFC 2911: 3.2.5 Get-Printer-Attributes Operation … … 236 235 237 236 # verify the request and get the attributes dictionary 238 req_dict = ipp.op s.verify_get_printer_attributes_request(request)237 req_dict = ipp.operations.verify_get_printer_attributes_request(request) 239 238 240 239 # lookup the printer name … … 246 245 247 246 # bulid response 248 response = ipp.op s.make_get_printer_attributes_response(247 response = ipp.operations.make_get_printer_attributes_response( 249 248 self.printers[printer_name].get_printer_attributes(request), request) 250 249 return response 251 250 252 @handler_for( consts.Operations.SET_PRINTER_ATTRIBUTES)251 @handler_for(ipp.OperationCodes.SET_PRINTER_ATTRIBUTES) 253 252 def set_printer_attributes(self, request): 254 253 raise ipp.errors.ServerErrorOperationNotSupported … … 256 255 ##### Job Commands 257 256 258 @handler_for( consts.Operations.CANCEL_JOB)257 @handler_for(ipp.OperationCodes.CANCEL_JOB) 259 258 def cancel_job(self, request): 260 259 raise ipp.errors.ServerErrorOperationNotSupported 261 260 262 @handler_for( consts.Operations.SEND_DOCUMENT)261 @handler_for(ipp.OperationCodes.SEND_DOCUMENT) 263 262 def send_document(self, request): 264 263 raise ipp.errors.ServerErrorOperationNotSupported 265 264 266 @handler_for( consts.Operations.SEND_URI)265 @handler_for(ipp.OperationCodes.SEND_URI) 267 266 def send_uri(self, request): 268 267 raise ipp.errors.ServerErrorOperationNotSupported 269 268 270 @handler_for( consts.Operations.GET_JOB_ATTRIBUTES)269 @handler_for(ipp.OperationCodes.GET_JOB_ATTRIBUTES) 271 270 def get_job_attributes(self, request): 272 271 273 272 # verify the request and get the attributes dictionary 274 req_dict = ipp.op s.verify_get_jobs_request(request)273 req_dict = ipp.operations.verify_get_jobs_request(request) 275 274 276 275 # lookup the printer name … … 291 290 # XXX: we need to honor the things that the request actually asks for 292 291 # build the response 293 response = ipp.op s.make_get_job_attributes_response(292 response = ipp.operations.make_get_job_attributes_response( 294 293 job.get_job_attributes(request), request) 295 294 return response 296 295 297 @handler_for( consts.Operations.SET_JOB_ATTRIBUTES)296 @handler_for(ipp.OperationCodes.SET_JOB_ATTRIBUTES) 298 297 def set_job_attributes(self, request): 299 298 raise ipp.errors.ServerErrorOperationNotSupported 300 299 301 @handler_for( consts.Operations.RESTART_JOB)300 @handler_for(ipp.OperationCodes.RESTART_JOB) 302 301 def restart_job(self, request): 303 302 raise ipp.errors.ServerErrorOperationNotSupported 304 303 305 @handler_for( consts.Operations.PROMOTE_JOB)304 @handler_for(ipp.OperationCodes.PROMOTE_JOB) 306 305 def promote_job(self, request): 307 306 raise ipp.errors.ServerErrorOperationNotSupported … … 309 308 ##### CUPS Specific Commands 310 309 311 @handler_for( consts.Operations.CUPS_GET_DOCUMENT)310 @handler_for(ipp.OperationCodes.CUPS_GET_DOCUMENT) 312 311 def cups_get_document(self, request): 313 312 raise ipp.errors.ServerErrorOperationNotSupported 314 313 315 @handler_for( consts.Operations.CUPS_GET_DEFAULT)314 @handler_for(ipp.OperationCodes.CUPS_GET_DEFAULT) 316 315 def cups_get_default(self, request): 317 316 """The CUPS-Get-Default operation (0x4001) returns the default … … 323 322 324 323 # verify the request and get the attributes dictionary 325 req_dict = ipp.op s.verify_cups_get_default_request(request)326 # build the response 327 response = ipp.op s.make_get_printer_attributes_response(324 req_dict = ipp.operations.verify_cups_get_default_request(request) 325 # build the response 326 response = ipp.operations.make_get_printer_attributes_response( 328 327 self.printers[self.default].get_printer_attributes(request), request) 329 328 return response 330 329 331 @handler_for( consts.Operations.CUPS_GET_PRINTERS)330 @handler_for(ipp.OperationCodes.CUPS_GET_PRINTERS) 332 331 def cups_get_printers(self, request): 333 332 """The CUPS-Get-Printers operation (0x4002) returns the … … 341 340 342 341 # verify the request and get the attributes dictionary 343 req_dict = ipp.op s.verify_cups_get_printers_request(request)342 req_dict = ipp.operations.verify_cups_get_printers_request(request) 344 343 # get the printer attributes 345 344 attrs = [self.printers[printer].get_printer_attributes(request) \ 346 345 for printer in self.printers] 347 346 # build the response 348 response = ipp.op s.make_cups_get_printers_response(attrs, request)349 return response 350 351 @handler_for( consts.Operations.CUPS_GET_CLASSES)347 response = ipp.operations.make_cups_get_printers_response(attrs, request) 348 return response 349 350 @handler_for(ipp.OperationCodes.CUPS_GET_CLASSES) 352 351 def cups_get_classes(self, request): 353 352 """The CUPS-Get-Classes operation (0x4005) returns the printer … … 361 360 362 361 # verify the request and get the attributes dictionaryu 363 req_dict = ipp.op s.verify_cups_get_classes_request(request)364 # build the response 365 response = ipp.op s.make_cups_get_classes_response(request)366 return response 362 req_dict = ipp.operations.verify_cups_get_classes_request(request) 363 # build the response 364 response = ipp.operations.make_cups_get_classes_response(request) 365 return response
Note: See TracChangeset
for help on using the changeset viewer.