Changeset ebf327d
- Timestamp:
- Mar 5, 2011, 10:42:40 PM (14 years ago)
- Branches:
- no-cups
- Children:
- 5cfb358
- Parents:
- cf1d291
- git-author:
- Jessica B. Hamrick <jhamrick@…> (03/05/11 22:42:40)
- git-committer:
- Jessica B. Hamrick <jhamrick@…> (03/05/11 22:42:40)
- Location:
- server/lib
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
server/lib/ippattribute.py
r2646571 rebf327d 2 2 3 3 import sys, struct, logging 4 from ippvalue import IPPValue4 from ippvalue import Value 5 5 6 6 # initialize logger 7 7 logger = logging.getLogger("ippLogger") 8 8 9 class IPPAttribute():9 class Attribute(): 10 10 """ 11 11 In addition to what the RFC reports, an attribute has an … … 42 42 def __init__(self, name, values): 43 43 """ 44 Initialize an IPPAttribute.44 Initialize an Attribute. 45 45 46 46 Arguments: … … 48 48 name -- the name of the attribute 49 49 50 values -- a list of IPPValues. May not be empty.50 values -- a list of Values. May not be empty. 51 51 """ 52 52 … … 56 56 # make sure the list of values isn't empty 57 57 assert len(values) > 0 58 # make sure each value is a n IPPValue59 for value in values: assert isinstance(value, IPPValue)58 # make sure each value is a Value 59 for value in values: assert isinstance(value, Value) 60 60 61 61 self.name = name -
server/lib/ippattributegroup.py
r2646571 rebf327d 2 2 3 3 import sys, struct, logging 4 from ippattribute import IPPAttribute4 from ippattribute import Attribute 5 5 6 6 # initialize logger 7 7 logger = logging.getLogger("ippLogger") 8 8 9 class IPPAttributeGroup():9 class AttributeGroup(): 10 10 """ 11 An IPPAttributeGroup consists of an attribute-group-tag, followed12 by a sequence of IPPAttributes.11 An AttributeGroup consists of an attribute-group-tag, followed by 12 a sequence of Attributes. 13 13 """ 14 14 15 15 def __init__(self, attribute_group_tag, attributes=[]): 16 16 """ 17 Initialize an IPPAttributeGroup.17 Initialize an AttributeGroup. 18 18 19 19 Arguments: … … 28 28 assert attribute_group_tag is not None 29 29 30 # make sure attributes is a list or tuple of IPPAttributes30 # make sure attributes is a list or tuple of Attributes 31 31 assert isinstance(attributes, (list, tuple)) 32 for a in attributes: assert isinstance(a, IPPAttribute)32 for a in attributes: assert isinstance(a, Attribute) 33 33 34 34 self.attribute_group_tag = attribute_group_tag … … 40 40 def toBinaryData(self): 41 41 """ 42 Convert the IPPAttributeGroup to binary.42 Convert the AttributeGroup to binary. 43 43 """ 44 44 -
server/lib/ipprequest.py
r2646571 rebf327d 2 2 3 3 import sys, struct, logging 4 from ippattributegroup import IPPAttributeGroup5 from ippattribute import IPPAttribute6 from ippvalue import IPPValue4 from ippattributegroup import AttributeGroup 5 from ippattribute import Attribute 6 from ippvalue import Value 7 7 8 8 # initialize logger 9 9 logger = logging.getLogger("ippLogger") 10 10 11 class IPPRequest():11 class Request(): 12 12 """ 13 13 From RFC 2565: … … 39 39 attribute_groups=[], data=None, request=None, length=sys.maxint): 40 40 """ 41 Create an IPPRequest. Takes either the segments of the 42 request separately, or a file handle for the request to parse. 43 If the file handle is passed in, all other arguments are 44 ignored. 41 Create a Request. Takes either the segments of the request 42 separately, or a file handle for the request to parse. If the 43 file handle is passed in, all other arguments are ignored. 45 44 46 45 Keyword arguments for passing in the segments of the request: … … 56 55 request itself. 57 56 58 attribute_groups -- a list of IPPAttributes, at least length 157 attribute_groups -- a list of Attributes, at least length 1 59 58 60 59 data -- (optional) variable length, containing the actual … … 77 76 # make sure the request id isn't empty 78 77 assert request_id is not None 79 # make sure attribute_groups is a list of IPPAttributes78 # make sure attribute_groups is a list of Attributes 80 79 assert len(attribute_groups) > 0 81 for a in attribute_groups: assert isinstance(a, IPPAttributeGroup)80 for a in attribute_groups: assert isinstance(a, AttributeGroup) 82 81 83 82 # if the request isn't None, then we'll read directly from … … 148 147 length -= value_length 149 148 150 ippvalue = IPPValue(value_tag, value)149 ippvalue = Value(value_tag, value) 151 150 logger.debug("value : %s" % ippvalue.value) 152 151 153 # create a new IPPAttribute from the data we just152 # create a new Attribute from the data we just 154 153 # read in, and add it to our attributes list 155 attributes.append( IPPAttribute(name, [ippvalue]))154 attributes.append(Attribute(name, [ippvalue])) 156 155 157 156 else: … … 165 164 length -= value_length 166 165 167 ippvalue = IPPValue(value_tag, value)166 ippvalue = Value(value_tag, value) 168 167 logger.debug("value : %s" % ippvalue.value) 169 168 … … 175 174 length -= 1 176 175 177 self.attribute_groups.append(IPPAttributeGroup(attribute_group_tag, attributes)) 176 self.attribute_groups.append(AttributeGroup( 177 attribute_group_tag, attributes)) 178 178 179 179 # once we hit the end-of-attributes tag, the only thing -
server/lib/ippvalue.py
r2646571 rebf327d 7 7 logger = logging.getLogger("ippLogger") 8 8 9 class IPPValue():9 class Value(): 10 10 """ 11 11 An IPP value consists of a tag and a value, and optionally, a name. … … 27 27 def __init__(self, value_tag, value, unpack=True): 28 28 """ 29 Initialize a n IPPValue:29 Initialize a Value: 30 30 31 31 Arguments:
Note: See TracChangeset
for help on using the changeset viewer.