Changeset dc40fe9
- Timestamp:
- Dec 20, 2011, 11:56:11 AM (12 years ago)
- Branches:
- no-cups
- Children:
- cf32fee
- Parents:
- 5b3a81e
- git-author:
- Jessica B. Hamrick <jhamrick@…> (12/20/11 11:56:11)
- git-committer:
- Jessica B. Hamrick <jhamrick@…> (12/20/11 11:56:11)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
server/lib/gutenbach/server/server.py
rc70a3c9 rdc40fe9 2 2 import BaseHTTPServer 3 3 import gutenbach.ipp as ipp 4 import gutenbach.ipp.constants as const5 4 import logging 6 5 import traceback 6 import sys 7 7 8 8 # initialize logger … … 29 29 logger.debug("Received request: %s" % repr(request)) 30 30 31 # Operation attributes -- typically the same for any request 32 attributes = [ 33 ipp.Attribute( 34 'attributes-charset', 35 [ipp.Value(ipp.Tags.CHARSET, 'utf-8')]), 36 ipp.Attribute( 37 'attributes-natural-language', 38 [ipp.Value(ipp.Tags.NATURAL_LANGUAGE, 'en-us')]) 39 ] 40 # Put the operation attributes in a group 41 attribute_group = ipp.AttributeGroup( 42 const.AttributeTags.OPERATION, 43 attributes) 31 # Create an empty response object 32 response = ipp.ops.make_empty_response(request) 44 33 45 # Set up the default response -- handlers will override these 46 # values if they need to 47 response_kwargs = {} 48 response_kwargs['version'] = request.version 49 response_kwargs['operation_id'] = const.StatusCodes.OK 50 response_kwargs['request_id'] = request.request_id 51 response_kwargs['attribute_groups'] = [attribute_group] 52 response = ipp.Request(**response_kwargs) 53 54 # Get the handler and pass it the request and response objects 34 # Get the handler and pass it the request and response 35 # objects. It will fill in values for the response object or 36 # thrown an error. 55 37 try: 56 38 self.root.handle(request, response) 57 except: 58 response.operation_id = const.StatusCodes.INTERNAL_ERROR 39 40 # Handle any errors that occur. If an exception occurs that 41 # is an IPP error, then we can get the error code from the 42 # exception itself. 43 except IPPException: 44 exctype, excval, exctb = sys.exc_info() 45 excval.update_response(response) 46 logger.error(traceback.format_exc()) 47 48 # If it wasn't an IPP error, then it's our fault, so mark it 49 # as an internal server error 50 except Exception: 51 response.operation_id = const.ErrorCodes.INTERNAL_ERROR 59 52 logger.error(traceback.format_exc()) 60 53
Note: See TracChangeset
for help on using the changeset viewer.