Ignore:
Timestamp:
Dec 23, 2011, 9:37:39 PM (12 years ago)
Author:
Jessica B. Hamrick <jhamrick@…>
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)
Message:

Reorganization

File:
1 edited

Legend:

Unmodified
Added
Removed
  • server/lib/gutenbach/server/requests.py

    rb828a96 r793432f  
    11from gutenbach.server.printer import GutenbachPrinter
    22import gutenbach.ipp as ipp
    3 import gutenbach.ipp.constants as consts
    43import logging
    54import traceback
     
    5453            exctype, excval, exctb = sys.exc_info()
    5554            logger.error("%s: %s" % (exctype.__name__, excval.message))
    56             response = ipp.ops.make_empty_response(request)
     55            response = ipp.operations.make_empty_response(request)
    5756            excval.update_response(response)
    5857
     
    6160        except Exception:
    6261            logger.error(traceback.format_exc())
    63             response = ipp.ops.make_empty_response(request)
     62            response = ipp.operations.make_empty_response(request)
    6463            response.operation_id = ipp.StatusCodes.INTERNAL_ERROR
    6564
     
    6867    def unknown_operation(self, request):
    6968        logger.warning("Received unknown operation 0x%x" % request.operation_id)
    70         response = ipp.ops.make_empty_response(request)
    71         response.operation_id = consts.StatusCodes.OPERATION_NOT_SUPPORTED
     69        response = ipp.operations.make_empty_response(request)
     70        response.operation_id = ipp.StatusCodes.OPERATION_NOT_SUPPORTED
    7271        return response
    7372       
    7473    ##### Printer Commands
    7574
    76     @handler_for(consts.Operations.PRINT_JOB)
     75    @handler_for(ipp.OperationCodes.PRINT_JOB)
    7776    def print_job(self, request):
    7877        """RFC 2911: 3.2.1 Print-Job Operation
     
    8887        raise ipp.errors.ServerErrorOperationNotSupported
    8988
    90     @handler_for(consts.Operations.VALIDATE_JOB)
     89    @handler_for(ipp.OperationCodes.VALIDATE_JOB)
    9190    def validate_job(self, request):
    9291
    9392        raise ipp.errors.ServerErrorOperationNotSupported
    9493
    95     @handler_for(consts.Operations.GET_JOBS)
     94    @handler_for(ipp.OperationCodes.GET_JOBS)
    9695    def get_jobs(self, request):
    9796        """RFC 2911: 3.2.6 Get-Jobs Operation
     
    110109
    111110        # verify the request and get an attribute dictionary
    112         req_dict = ipp.ops.verify_get_jobs_request(request)
     111        req_dict = ipp.operations.verify_get_jobs_request(request)
    113112
    114113        # lookup printer name
     
    124123
    125124        # build the response
    126         response = ipp.ops.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)
    130129    def print_uri(self, request):
    131130        raise ipp.errors.ServerErrorOperationNotSupported
    132131
    133     @handler_for(consts.Operations.CREATE_JOB)
     132    @handler_for(ipp.OperationCodes.CREATE_JOB)
    134133    def create_job(self, request):
    135134        """RFC 2911: 3.2.4 Create-Job Operation
     
    183182        raise ipp.errors.ServerErrorOperationNotSupported
    184183   
    185     @handler_for(consts.Operations.PAUSE_PRINTER)
     184    @handler_for(ipp.OperationCodes.PAUSE_PRINTER)
    186185    def pause_printer(self, request):
    187186        raise ipp.errors.ServerErrorOperationNotSupported
    188187
    189     @handler_for(consts.Operations.RESUME_PRINTER)
     188    @handler_for(ipp.OperationCodes.RESUME_PRINTER)
    190189    def resume_printer(self, request):
    191190        raise ipp.errors.ServerErrorOperationNotSupported
    192191
    193     @handler_for(consts.Operations.GET_PRINTER_ATTRIBUTES)
     192    @handler_for(ipp.OperationCodes.GET_PRINTER_ATTRIBUTES)
    194193    def get_printer_attributes(self, request):
    195194        """RFC 2911: 3.2.5 Get-Printer-Attributes Operation
     
    236235
    237236        # verify the request and get the attributes dictionary
    238         req_dict = ipp.ops.verify_get_printer_attributes_request(request)
     237        req_dict = ipp.operations.verify_get_printer_attributes_request(request)
    239238
    240239        # lookup the printer name
     
    246245
    247246        # bulid response
    248         response = ipp.ops.make_get_printer_attributes_response(
     247        response = ipp.operations.make_get_printer_attributes_response(
    249248            self.printers[printer_name].get_printer_attributes(request), request)
    250249        return response
    251250
    252     @handler_for(consts.Operations.SET_PRINTER_ATTRIBUTES)
     251    @handler_for(ipp.OperationCodes.SET_PRINTER_ATTRIBUTES)
    253252    def set_printer_attributes(self, request):
    254253        raise ipp.errors.ServerErrorOperationNotSupported
     
    256255    ##### Job Commands
    257256
    258     @handler_for(consts.Operations.CANCEL_JOB)
     257    @handler_for(ipp.OperationCodes.CANCEL_JOB)
    259258    def cancel_job(self, request):
    260259        raise ipp.errors.ServerErrorOperationNotSupported
    261260
    262     @handler_for(consts.Operations.SEND_DOCUMENT)
     261    @handler_for(ipp.OperationCodes.SEND_DOCUMENT)
    263262    def send_document(self, request):
    264263        raise ipp.errors.ServerErrorOperationNotSupported
    265264
    266     @handler_for(consts.Operations.SEND_URI)
     265    @handler_for(ipp.OperationCodes.SEND_URI)
    267266    def send_uri(self, request):
    268267        raise ipp.errors.ServerErrorOperationNotSupported
    269268
    270     @handler_for(consts.Operations.GET_JOB_ATTRIBUTES)
     269    @handler_for(ipp.OperationCodes.GET_JOB_ATTRIBUTES)
    271270    def get_job_attributes(self, request):
    272271       
    273272        # verify the request and get the attributes dictionary
    274         req_dict = ipp.ops.verify_get_jobs_request(request)
     273        req_dict = ipp.operations.verify_get_jobs_request(request)
    275274       
    276275        # lookup the printer name
     
    291290        # XXX: we need to honor the things that the request actually asks for
    292291        # build the response
    293         response = ipp.ops.make_get_job_attributes_response(
     292        response = ipp.operations.make_get_job_attributes_response(
    294293            job.get_job_attributes(request), request)
    295294        return response
    296295
    297     @handler_for(consts.Operations.SET_JOB_ATTRIBUTES)
     296    @handler_for(ipp.OperationCodes.SET_JOB_ATTRIBUTES)
    298297    def set_job_attributes(self, request):
    299298        raise ipp.errors.ServerErrorOperationNotSupported
    300299
    301     @handler_for(consts.Operations.RESTART_JOB)
     300    @handler_for(ipp.OperationCodes.RESTART_JOB)
    302301    def restart_job(self, request):
    303302        raise ipp.errors.ServerErrorOperationNotSupported
    304303
    305     @handler_for(consts.Operations.PROMOTE_JOB)
     304    @handler_for(ipp.OperationCodes.PROMOTE_JOB)
    306305    def promote_job(self, request):
    307306        raise ipp.errors.ServerErrorOperationNotSupported
     
    309308    ##### CUPS Specific Commands
    310309
    311     @handler_for(consts.Operations.CUPS_GET_DOCUMENT)
     310    @handler_for(ipp.OperationCodes.CUPS_GET_DOCUMENT)
    312311    def cups_get_document(self, request):
    313312        raise ipp.errors.ServerErrorOperationNotSupported
    314313
    315     @handler_for(consts.Operations.CUPS_GET_DEFAULT)
     314    @handler_for(ipp.OperationCodes.CUPS_GET_DEFAULT)
    316315    def cups_get_default(self, request):
    317316        """The CUPS-Get-Default operation (0x4001) returns the default
     
    323322
    324323        # verify the request and get the attributes dictionary
    325         req_dict = ipp.ops.verify_cups_get_default_request(request)
    326         # build the response
    327         response = ipp.ops.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(
    328327            self.printers[self.default].get_printer_attributes(request), request)
    329328        return response
    330329
    331     @handler_for(consts.Operations.CUPS_GET_PRINTERS)
     330    @handler_for(ipp.OperationCodes.CUPS_GET_PRINTERS)
    332331    def cups_get_printers(self, request):
    333332        """The CUPS-Get-Printers operation (0x4002) returns the
     
    341340
    342341        # verify the request and get the attributes dictionary
    343         req_dict = ipp.ops.verify_cups_get_printers_request(request)
     342        req_dict = ipp.operations.verify_cups_get_printers_request(request)
    344343        # get the printer attributes
    345344        attrs = [self.printers[printer].get_printer_attributes(request) \
    346345                 for printer in self.printers]
    347346        # build the response
    348         response = ipp.ops.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)
    352351    def cups_get_classes(self, request):
    353352        """The CUPS-Get-Classes operation (0x4005) returns the printer
     
    361360
    362361        # verify the request and get the attributes dictionaryu
    363         req_dict = ipp.ops.verify_cups_get_classes_request(request)
    364         # build the response
    365         response = ipp.ops.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.