Changeset 91abb7f for server/lib/server.py
- Timestamp:
- Mar 10, 2011, 10:39:48 PM (14 years ago)
- 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)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
server/lib/server.py
r16055f9 r91abb7f 2 2 3 3 import logging, BaseHTTPServer 4 from ipprequest import * 5 import ipp constants as const4 import ipp 5 import ipp.constants as const 6 6 7 7 logging.basicConfig(level=logging.DEBUG) … … 19 19 def handle_ipp(self): 20 20 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) 23 23 24 24 response_kwargs = {} … … 26 26 response_kwargs['request_id'] = request.request_id 27 27 response_kwargs = self.get_jobs(request, response_kwargs) 28 response = IPPRequest(**response_kwargs)28 response = ipp.Request(**response_kwargs) 29 29 30 30 self.send_response(200, "o hai") … … 32 32 self.send_header("Connection", "close") 33 33 self.end_headers() 34 self.wfile.write(response. toBinaryData())34 self.wfile.write(response.packed_value) 35 35 36 #def get_jobs(self, request, response_kwargs):37 #"""get-jobs response"""36 def get_jobs(self, request, response_kwargs): 37 """get-jobs response""" 38 38 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 )])] 63 63 64 64 65 # #req_op_attributes = request.getAttributeGroup(IPPTags.OPERATION_ATTRIBUTES_TAG)66 ##print req_op_attributes67 ##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') 68 68 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 )])] 77 77 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_OK78 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 84 84 85 #return response_kwargs85 return response_kwargs 86 86 87 87 ##### Printer Commands … … 96 96 pass 97 97 98 def get_jobs(self, request):99 pass98 #def get_jobs(self, request): 99 # pass 100 100 101 101 def print_uri(self, request):
Note: See TracChangeset
for help on using the changeset viewer.