Changeset 91abb7f


Ignore:
Timestamp:
Mar 10, 2011, 10:39:48 PM (13 years ago)
Author:
Quentin Smith <quentin@…>
Branches:
no-cups
Children:
94211df
Parents:
01e3017
git-author:
Quentin Smith <quentin@…> (03/10/11 22:39:48)
git-committer:
Quentin Smith <quentin@…> (03/10/11 22:39:48)
Message:

Restore server.py to its previous functional state

Location:
server/lib
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • server/lib/ipp/__init__.py

    r7a1c039 r91abb7f  
     1from attribute import Attribute
     2from attributegroup import AttributeGroup
     3from request import Request
     4from value import Value
     5from constants import Tags
  • server/lib/ipp/constants.py

    r7a1c039 r91abb7f  
    185185    def __init__(self): pass
    186186
     187class StatusCodes(SuccessCodes, ClientErrorCodes, ServerErrorCodes):
     188    pass
     189
    187190class CUPSPrinterType():
    188191    """
     
    307310    MIME_MEDIA_TYPE       = 0x49                                   
    308311    MEMBER_ATTR_NAME      = 0x4a
     312
     313class Tags(AttributeTags, OutOfBandTags, IntegerTags, OctetStringTags, CharacterStringTags):
     314    pass
  • server/lib/server.py

    r16055f9 r91abb7f  
    22
    33import logging, BaseHTTPServer
    4 from ipprequest import *
    5 import ippconstants as const
     4import ipp
     5import ipp.constants as const
    66
    77logging.basicConfig(level=logging.DEBUG)
     
    1919    def handle_ipp(self):
    2020        length = int(self.headers.getheader('content-length', 0))
    21         request = IPPRequest(request=self.rfile,
    22                              length=length)
     21        request = ipp.Request(request=self.rfile,
     22                              length=length)
    2323
    2424        response_kwargs = {}
     
    2626        response_kwargs['request_id'] = request.request_id
    2727        response_kwargs = self.get_jobs(request, response_kwargs)
    28         response = IPPRequest(**response_kwargs)
     28        response = ipp.Request(**response_kwargs)
    2929
    3030        self.send_response(200, "o hai")
     
    3232        self.send_header("Connection", "close")
    3333        self.end_headers()
    34         self.wfile.write(response.toBinaryData())
     34        self.wfile.write(response.packed_value)
    3535
    36     # def get_jobs(self, request, response_kwargs):
    37     #     """get-jobs response"""
     36    def get_jobs(self, request, response_kwargs):
     37        """get-jobs response"""
    3838
    39     #     job_attributes = [IPPAttribute('job-id',
    40     #                                    [IPPValue(IPPTags.INTEGER,
    41     #                                              12345,
    42     #                                              unpack=False)]),
    43     #                       IPPAttribute('job-name',
    44     #                                    [IPPValue(IPPTags.NAME_WITHOUT_LANGUAGE,
    45     #                                              'foo',
    46     #                                              unpack=False)]),
    47     #                       IPPAttribute('job-originating-user-name',
    48     #                                    [IPPValue(IPPTags.NAME_WITHOUT_LANGUAGE,
    49     #                                              'jhamrick',
    50     #                                              unpack=False)]),
    51     #                       IPPAttribute('job-k-octets',
    52     #                                    [IPPValue(IPPTags.INTEGER,
    53     #                                              1,
    54     #                                              unpack=False)]),
    55     #                       IPPAttribute('job-state',
    56     #                                    [IPPValue(IPPTags.ENUM,
    57     #                                              const.IPP_JOB_HELD,
    58     #                                              unpack=False)]),
    59     #                       IPPAttribute('job-printer-uri',
    60     #                                    [IPPValue(IPPTags.URI,
    61     #                                              'http://localhost:8000/printers/foo',
    62     #                                              unpack=False)])]
     39        job_attributes = [ipp.Attribute('job-id',
     40                                       [ipp.Value(ipp.Tags.INTEGER,
     41                                                 12345,
     42                                                 )]),
     43                          ipp.Attribute('job-name',
     44                                       [ipp.Value(ipp.Tags.NAME_WITHOUT_LANGUAGE,
     45                                                 'foo',
     46                                                 )]),
     47                          ipp.Attribute('job-originating-user-name',
     48                                       [ipp.Value(ipp.Tags.NAME_WITHOUT_LANGUAGE,
     49                                                 'jhamrick',
     50                                                 )]),
     51                          ipp.Attribute('job-k-octets',
     52                                       [ipp.Value(ipp.Tags.INTEGER,
     53                                                 1,
     54                                                 )]),
     55                          ipp.Attribute('job-state',
     56                                       [ipp.Value(ipp.Tags.ENUM,
     57                                                 const.JobStates.HELD,
     58                                                 )]),
     59                          ipp.Attribute('job-printer-uri',
     60                                       [ipp.Value(ipp.Tags.URI,
     61                                                 'http://localhost:8000/printers/foo',
     62                                                 )])]
    6363
    6464
    65     #     #req_op_attributes = request.getAttributeGroup(IPPTags.OPERATION_ATTRIBUTES_TAG)
    66     #     #print req_op_attributes
    67     #     #printer_uri = req_op_attributes[0].getAttribute('printer-uri')
     65        #req_op_attributes = request.getAttributeGroup(ipp.Tags.OPERATION_ATTRIBUTES_TAG)
     66        #print req_op_attributes
     67        #printer_uri = req_op_attributes[0].getAttribute('printer-uri')
    6868
    69     #     op_attributes = [IPPAttribute('attributes-charset',
    70     #                                   [IPPValue(IPPTags.CHARSET,
    71     #                                             'utf-8',
    72     #                                             unpack=False)]),
    73     #                      IPPAttribute('attributes-natural-language',
    74     #                                   [IPPValue(IPPTags.NATURAL_LANGUAGE,
    75     #                                             'en-us',
    76     #                                             unpack=False)])]
     69        op_attributes = [ipp.Attribute('attributes-charset',
     70                                      [ipp.Value(ipp.Tags.CHARSET,
     71                                                'utf-8',
     72                                                )]),
     73                         ipp.Attribute('attributes-natural-language',
     74                                      [ipp.Value(ipp.Tags.NATURAL_LANGUAGE,
     75                                                'en-us',
     76                                                )])]
    7777       
    78     #     job_attribute_group = IPPAttributeGroup(IPPTags.JOB_ATTRIBUTES_TAG,
    79     #                                             job_attributes)
    80     #     op_attributes_group = IPPAttributeGroup(IPPTags.OPERATION_ATTRIBUTES_TAG,
    81     #                                             op_attributes)
    82     #     response_kwargs['attribute_groups'] = [op_attributes_group,job_attribute_group]
    83     #     response_kwargs['operation_id'] = const.IPP_OK
     78        job_attribute_group = ipp.AttributeGroup(const.AttributeTags.JOB,
     79                                                 job_attributes)
     80        op_attributes_group = ipp.AttributeGroup(const.AttributeTags.OPERATION,
     81                                                 op_attributes)
     82        response_kwargs['attribute_groups'] = [op_attributes_group,job_attribute_group]
     83        response_kwargs['operation_id'] = const.StatusCodes.OK
    8484
    85     #     return response_kwargs
     85        return response_kwargs
    8686
    8787    ##### Printer Commands
     
    9696        pass
    9797
    98     def get_jobs(self, request):
    99         pass
     98    #def get_jobs(self, request):
     99    #    pass
    100100
    101101    def print_uri(self, request):
Note: See TracChangeset for help on using the changeset viewer.