- Timestamp:
- Dec 20, 2011, 3:24:01 PM (12 years ago)
- Branches:
- no-cups
- Children:
- 5e44432
- Parents:
- 59a1d4a
- git-author:
- Jessica B. Hamrick <jhamrick@…> (12/20/11 15:24:01)
- git-committer:
- Jessica B. Hamrick <jhamrick@…> (12/20/11 15:24:01)
- Location:
- server/lib/gutenbach
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
server/lib/gutenbach/ipp/operations.py
r59a1d4a raef164a 1 from .value import Value2 1 from .attribute import Attribute 3 2 from .attributegroup import AttributeGroup 4 3 from .request import Request 4 from .value import Value 5 5 import constants as consts 6 6 import exceptions as err -
server/lib/gutenbach/server/requests.py
r59a1d4a raef164a 1 1 from gutenbach.server.printer import GutenbachPrinter 2 2 import gutenbach.ipp as ipp 3 import gutenbach.ipp.constants as const 3 import gutenbach.ipp.constants as consts 4 4 import logging 5 5 … … 41 41 handler = getattr(self, handler_name) 42 42 logger.info("Handling request of type '%s'" % handler_name) 43 response = handler(request) 43 44 # Try to handle the request 45 try: 46 response = handler(request) 47 48 # Handle any errors that occur. If an exception occurs that 49 # is an IPP error, then we can get the error code from the 50 # exception itself. 51 except ipp.errors.IPPException: 52 exctype, excval, exctb = sys.exc_info() 53 logger.error(traceback.format_exc()) 54 response = ipp.ops.make_empty_response(request) 55 excval.update_response(response) 56 57 # If it wasn't an IPP error, then it's our fault, so mark it 58 # as an internal server error 59 except Exception: 60 logger.error(traceback.format_exc()) 61 response = ipp.ops.make_empty_response(request) 62 response.operation_id = ipp.StatusCodes.INTERNAL_ERROR 63 44 64 return response 45 65 … … 47 67 logger.warning("Received unknown operation 0x%x" % request.operation_id) 48 68 response = ipp.ops.make_empty_response(request) 49 response.operation_id = const .StatusCodes.OPERATION_NOT_SUPPORTED69 response.operation_id = consts.StatusCodes.OPERATION_NOT_SUPPORTED 50 70 return response 51 71 … … 58 78 pass 59 79 60 @handler_for(const .Operations.GET_JOBS)80 @handler_for(consts.Operations.GET_JOBS) 61 81 def get_jobs(self, request): 62 82 """RFC 2911: 3.2.6 Get-Jobs Operation … … 104 124 pass 105 125 106 @handler_for(const .Operations.GET_PRINTER_ATTRIBUTES)126 @handler_for(consts.Operations.GET_PRINTER_ATTRIBUTES) 107 127 def get_printer_attributes(self, request): 108 128 """RFC 2911: 3.2.5 Get-Printer-Attributes Operation … … 217 237 ##### CUPS Specific Commands 218 238 219 @handler_for(const .Operations.CUPS_GET_DEFAULT)239 @handler_for(consts.Operations.CUPS_GET_DEFAULT) 220 240 def cups_get_default(self, request): 221 241 """The CUPS-Get-Default operation (0x4001) returns the default … … 233 253 return response 234 254 235 @handler_for(const .Operations.CUPS_GET_PRINTERS)255 @handler_for(consts.Operations.CUPS_GET_PRINTERS) 236 256 def cups_get_printers(self, request): 237 257 """The CUPS-Get-Printers operation (0x4002) returns the … … 253 273 return response 254 274 255 @handler_for(const .Operations.CUPS_GET_CLASSES)275 @handler_for(consts.Operations.CUPS_GET_CLASSES) 256 276 def cups_get_classes(self, request): 257 277 """The CUPS-Get-Classes operation (0x4005) returns the printer -
server/lib/gutenbach/server/server.py
ref8df33 raef164a 3 3 import gutenbach.ipp as ipp 4 4 import logging 5 import sys 5 6 import traceback 6 import sys7 7 8 8 # initialize logger … … 27 27 length = int(self.headers.getheader('content-length', 0)) 28 28 request = ipp.Request(request=self.rfile, length=length) 29 logger.debug("Received request: %s" % repr(request))30 29 31 30 # Get the handler and pass it the request and response 32 31 # objects. It will fill in values for the response object or 33 # thrown an error. 32 # throw a fatal error. 33 logger.debug("Received request: %s" % repr(request)) 34 34 try: 35 35 response = self.root.handle(request) 36 37 # Handle any errors that occur. If an exception occurs that 38 # is an IPP error, then we can get the error code from the 39 # exception itself. 40 except ipp.errors.IPPException: 41 exctype, excval, exctb = sys.exc_info() 42 logger.error(traceback.format_exc()) 43 response = ipp.ops.make_empty_response(request) 44 excval.update_response(response) 45 46 # If it wasn't an IPP error, then it's our fault, so mark it 47 # as an internal server error 48 except Exception: 49 logger.error(traceback.format_exc()) 50 response = ipp.ops.make_empty_response(request) 51 response.operation_id = ipp.StatusCodes.INTERNAL_ERROR 36 except: 37 logger.fatal(traceback.format_exc()) 38 sys.exit(1) 52 39 53 40 # Send the response across HTTP
Note: See TracChangeset
for help on using the changeset viewer.