Changeset 793432f for server/lib/gutenbach/server/requests.py
- 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)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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.