- Timestamp:
- Dec 20, 2011, 1:47:35 PM (12 years ago)
- Branches:
- no-cups
- Children:
- cad7502
- Parents:
- f6c6897
- git-author:
- Jessica B. Hamrick <jhamrick@…> (12/20/11 13:47:35)
- git-committer:
- Jessica B. Hamrick <jhamrick@…> (12/20/11 13:47:35)
- Location:
- server/lib/gutenbach/server
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
server/lib/gutenbach/server/__init__.py
r7bd1035 r6effd50 2 2 import BaseHTTPServer 3 3 import logging 4 import sys 4 5 5 6 # configure logging 6 logging.basicConfig(level=logging.INFO) 7 logging.basicConfig(level=logging.DEBUG) 8 9 def error(self, request, client_address): 10 sys.exit(1) 7 11 8 12 def start(): 9 13 server_address = ('', 8000) 10 14 httpd = BaseHTTPServer.HTTPServer(server_address, GutenbachIPPServer) 15 httpd.handle_error = error.__get__(httpd) 11 16 httpd.serve_forever() 12 17 -
server/lib/gutenbach/server/printer.py
r5fe360e r6effd50 61 61 def __getattr__(self, attr): 62 62 try: 63 return s uper(Printer, self).__getattr__(attr)63 return self.__getattribute__(attr) 64 64 except AttributeError: 65 65 pass 66 67 return super(Printer, self).__getattr__( 68 attr.replace("-", "_")) 66 return self.__getattribute__(attr.replace("-", "_")) 69 67 70 68 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 has69 try: 70 getattr(self, attr) 71 return True 72 except AttributeError: 73 return False 76 74 77 75 ## Printer attributes … … 156 154 def get_printer_attributes(self, request): 157 155 attributes = [(attr, getattr(self, attr)) for attr in self.attributes] 158 attributes = map(lambda x: x if isinstance(x, (tuple, list)) else [x], attributes) 156 attributes = map(lambda x: x if isinstance(x[1], (tuple, list)) else (x[0], [x[1]]), 157 attributes) 159 158 return attributes 160 159 -
server/lib/gutenbach/server/requests.py
r5fe360e r6effd50 53 53 attrs = printer.get_printer_attributes(request) 54 54 ipp_attrs = [] 55 for attr, vals in enumerate(attrs):55 for attr, vals in attrs: 56 56 ipp_vals = [ipp.Value( 57 57 tag=printer_attribute_value_tags[attr], … … 64 64 attrs = job.get_job_attributes(request) 65 65 ipp_attrs = [] 66 for attr, vals in enumerate(attrs):66 for attr, vals in attrs: 67 67 ipp_vals = [ipp.Value( 68 68 tag=job_attribute_value_tags[attr], -
server/lib/gutenbach/server/server.py
rdc40fe9 r6effd50 41 41 # is an IPP error, then we can get the error code from the 42 42 # exception itself. 43 except IPPException:43 except ipp.errors.IPPException: 44 44 exctype, excval, exctb = sys.exc_info() 45 45 excval.update_response(response) … … 49 49 # as an internal server error 50 50 except Exception: 51 response.operation_id = const.ErrorCodes.INTERNAL_ERROR51 response.operation_id = ipp.StatusCodes.INTERNAL_ERROR 52 52 logger.error(traceback.format_exc()) 53 53 54 54 # Send the response across HTTP 55 55 logger.debug("Sending response: %s" % repr(response)) 56 try: 57 binary = response.packed_value 58 except: 59 logger.fatal(traceback.format_exc()) 60 sys.exit(1) 61 56 62 self.send_response(200, "Gutenbach IPP Response") 57 63 self.send_header("Content-Type", "application/ipp") 58 64 self.send_header("Connection", "close") 59 65 self.end_headers() 60 self.wfile.write( response.packed_value)66 self.wfile.write(binary)
Note: See TracChangeset
for help on using the changeset viewer.