Changeset 2646571 for server/lib
- Timestamp:
- Mar 5, 2011, 10:36:40 PM (14 years ago)
- Branches:
- no-cups
- Children:
- cf1d291
- Parents:
- 8979f90
- git-author:
- Jessica B. Hamrick <jhamrick@…> (03/05/11 22:36:40)
- git-committer:
- Jessica B. Hamrick <jhamrick@…> (03/05/11 22:36:40)
- Location:
- server/lib
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
server/lib/ippattribute.py
r8979f90 r2646571 2 2 3 3 import sys, struct, logging 4 from ippvalue import IPPValue 4 5 5 6 # initialize logger -
server/lib/ippattributegroup.py
r8979f90 r2646571 2 2 3 3 import sys, struct, logging 4 from ippattribute import IPPAttribute 4 5 5 6 # initialize logger -
server/lib/ipprequest.py
r8979f90 r2646571 2 2 3 3 import sys, struct, logging 4 from ippattributegroup import IPPAttributeGroup 5 from ippattribute import IPPAttribute 6 from ippvalue import IPPValue 4 7 5 8 # initialize logger … … 108 111 # as long as the next byte isn't signaling the end of the 109 112 # attributes, keep looping and parsing attributes 110 while next_byte != IPPTags.END_OF_ATTRIBUTES_TAG:113 while next_byte != AttributeTags.END: 111 114 112 115 attribute_group_tag = next_byte … … 130 133 logger.debug("name-length : %i" % name_length) 131 134 132 if name_length != IPPTags.ZERO_NAME_LENGTH:135 if name_length != AttributeTags.ZERO_NAME_LENGTH: 133 136 # read the name (a string of name_length bytes) 134 137 name = request.read(name_length) … … 209 212 210 213 # conver the end-of-attributes-tag to binary 211 end_of_attributes_tag = struct.pack('>b', IPPTags.END_OF_ATTRIBUTES_TAG)214 end_of_attributes_tag = struct.pack('>b', AttributeTags.END) 212 215 213 216 # convert the data to binary -
server/lib/ippvalue.py
r8979f90 r2646571 2 2 3 3 import sys, struct, logging 4 from ippconstants import * 4 5 5 6 # initialize logger … … 46 47 47 48 # out-of-band value tags 48 if self.value_tag == IPPTags.UNSUPPORTED or \49 self.value_tag == IPPTags.DEFAULT or \50 self.value_tag == IPPTags.UNKNOWN or \51 self.value_tag == IPPTags.NO_VALUE:49 if self.value_tag == OutOfBandTags.UNSUPPORTED or \ 50 self.value_tag == OutOfBandTags.DEFAULT or \ 51 self.value_tag == OutOfBandTags.UNKNOWN or \ 52 self.value_tag == OutOfBandTags.NO_VALUE: 52 53 self.value = '' 53 54 54 55 # integer value tags 55 elif self.value_tag == I PPTags.GENERIC_INTEGER:56 elif self.value_tag == IntegerTags.GENERIC: 56 57 pass # not supported 57 elif self.value_tag == I PPTags.INTEGER:58 elif self.value_tag == IntegerTags.INTEGER: 58 59 self.value = struct.unpack('>i', value)[0] 59 elif self.value_tag == I PPTags.BOOLEAN:60 elif self.value_tag == IntegerTags.BOOLEAN: 60 61 self.value = struct.unpack('>?', value)[0] 61 elif self.value_tag == I PPTags.ENUM:62 elif self.value_tag == IntegerTags.ENUM: 62 63 self.value = struct.unpack('>i', value)[0] 63 64 64 65 # octet string value tags 65 elif self.value_tag == IPPTags.UNSPECIFIED_OCTETSTRING:66 elif self.value_tag == OctetStringTags.UNSPECIFIED_OCTETSTRING: 66 67 pass 67 68 68 elif self.value_tag == IPPTags.DATETIME:69 elif self.value_tag == OctetStringTags.DATETIME: 69 70 # field octets contents range 70 71 # ----- ------ -------- ----- … … 83 84 self.value = struct.unpack('>hbbbbbbcbb', value)[0] 84 85 85 elif self.value_tag == IPPTags.RESOLUTION:86 elif self.value_tag == OctetStringTags.RESOLUTION: 86 87 # OCTET-STRING consisting of nine octets of 2 87 88 # SIGNED-INTEGERs followed by a SIGNED-BYTE. The first … … 93 94 self.value = struct.unpack('>iib', value) 94 95 95 elif self.value_tag == IPPTags.RANGE_OF_INTEGER:96 elif self.value_tag == OctetStringTags.RANGE_OF_INTEGER: 96 97 # Eight octets consisting of 2 SIGNED-INTEGERs. The first 97 98 # SIGNED-INTEGER contains the lower bound and the second … … 100 101 self.value = struct.unpack('>ii', value) 101 102 102 elif self.value_tag == IPPTags.TEXT_WITH_LANGUAGE or \103 self.value_tag == IPPTags.NAME_WITH_LANGUAGE:103 elif self.value_tag == OctetStringTags.TEXT_WITH_LANGUAGE or \ 104 self.value_tag == OctetStringTags.NAME_WITH_LANGUAGE: 104 105 a = struct.unpack('>h', value[:2])[0] 105 106 b = struct.unpack('>%ss' % a, value[2:a+2])[0] … … 109 110 110 111 # character string value tags 111 elif self.value_tag == IPPTags.TEXT_WITHOUT_LANGUAGE or \112 self.value_tag == IPPTags.NAME_WITHOUT_LANGUAGE:112 elif self.value_tag == CharacterStringTags.TEXT_WITHOUT_LANGUAGE or \ 113 self.value_tag == CharacterStringTags.NAME_WITHOUT_LANGUAGE: 113 114 self.value = str(value) 114 elif self.value_tag == IPPTags.GENERIC_CHAR_STRINGor \115 self.value_tag == IPPTags.KEYWORD or \116 self.value_tag == IPPTags.URI or \117 self.value_tag == IPPTags.URI_SCHEME or \118 self.value_tag == IPPTags.CHARSET or \119 self.value_tag == IPPTags.NATURAL_LANGUAGE or \120 self.value_tag == IPPTags.MIME_MEDIA_TYPE:115 elif self.value_tag == CharacterStringTags.GENERIC or \ 116 self.value_tag == CharacterStringTags.KEYWORD or \ 117 self.value_tag == CharacterStringTags.URI or \ 118 self.value_tag == CharacterStringTags.URI_SCHEME or \ 119 self.value_tag == CharacterStringTags.CHARSET or \ 120 self.value_tag == CharacterStringTags.NATURAL_LANGUAGE or \ 121 self.value_tag == CharacterStringTags.MIME_MEDIA_TYPE: 121 122 self.value = str(value) 122 123 … … 124 125 125 126 # out-of-band value tags 126 if self.value_tag == IPPTags.UNSUPPORTED or \127 self.value_tag == IPPTags.DEFAULT or \128 self.value_tag == IPPTags.UNKNOWN or \129 self.value_tag == IPPTags.NO_VALUE:127 if self.value_tag == OutOfBandTags.UNSUPPORTED or \ 128 self.value_tag == OutOfBandTags.DEFAULT or \ 129 self.value_tag == OutOfBandTags.UNKNOWN or \ 130 self.value_tag == OutOfBandTags.NO_VALUE: 130 131 return (0, '') 131 132 132 133 # integer value tags 133 elif self.value_tag == I PPTags.GENERIC_INTEGER:134 elif self.value_tag == IntegerTags.GENERIC: 134 135 pass 135 elif self.value_tag == I PPTags.INTEGER:136 elif self.value_tag == IntegerTags.INTEGER: 136 137 return (4, struct.pack('>i', self.value)) 137 elif self.value_tag == I PPTags.BOOLEAN:138 elif self.value_tag == IntegerTags.BOOLEAN: 138 139 return (1, struct.pack('>?', self.value)) 139 elif self.value_tag == I PPTags.ENUM:140 elif self.value_tag == IntegerTags.ENUM: 140 141 return (4, struct.pack('>i', self.value)) 141 142 142 143 # octet string value tags 143 elif self.value_tag == IPPTags.UNSPECIFIED_OCTETSTRING:144 elif self.value_tag == OctetStringTags.UNSPECIFIED_OCTETSTRING: 144 145 pass 145 elif self.value_tag == IPPTags.DATETIME:146 elif self.value_tag == OctetStringTags.DATETIME: 146 147 # field octets contents range 147 148 # ----- ------ -------- ----- … … 160 161 return (11, struct.pack('>hbbbbbbcbb', self.value)) 161 162 162 elif self.value_tag == IPPTags.RESOLUTION:163 elif self.value_tag == OctetStringTags.RESOLUTION: 163 164 # OCTET-STRING consisting of nine octets of 2 164 165 # SIGNED-INTEGERs followed by a SIGNED-BYTE. The first … … 170 171 return (9, struct.pack('>iib', self.value)) 171 172 172 elif self.value_tag == IPPTags.RANGE_OF_INTEGER:173 elif self.value_tag == OctetStringTags.RANGE_OF_INTEGER: 173 174 # Eight octets consisting of 2 SIGNED-INTEGERs. The first 174 175 # SIGNED-INTEGER contains the lower bound and the second … … 177 178 return (8, struct.pack('>ii', self.value)) 178 179 179 elif self.value_tag == IPPTags.TEXT_WITH_LANGUAGE or \180 self.value_tag == IPPTags.NAME_WITH_LANGUAGE:180 elif self.value_tag == OctetStringTags.TEXT_WITH_LANGUAGE or \ 181 self.value_tag == OctetStringTags.NAME_WITH_LANGUAGE: 181 182 a_bin = struct.pack('>h', self.value[0]) 182 183 b_bin = struct.pack('>%ss' % self.value[0], self.value[1]) … … 187 188 188 189 # character string value tags 189 elif self.value_tag == IPPTags.TEXT_WITHOUT_LANGUAGE or \190 self.value_tag == IPPTags.NAME_WITHOUT_LANGUAGE:190 elif self.value_tag == CharacterStringTags.TEXT_WITHOUT_LANGUAGE or \ 191 self.value_tag == CharacterStringTags.NAME_WITHOUT_LANGUAGE: 191 192 return (len(self.value), struct.pack('>%ss' % len(self.value), self.value)) 192 elif self.value_tag == IPPTags.GENERIC_CHAR_STRINGor \193 self.value_tag == IPPTags.KEYWORD or \194 self.value_tag == IPPTags.URI or \195 self.value_tag == IPPTags.URI_SCHEME or \196 self.value_tag == IPPTags.CHARSET or \197 self.value_tag == IPPTags.NATURAL_LANGUAGE or \198 self.value_tag == IPPTags.MIME_MEDIA_TYPE:193 elif self.value_tag == CharacterStringTags.GENERIC or \ 194 self.value_tag == CharacterStringTags.KEYWORD or \ 195 self.value_tag == CharacterStringTags.URI or \ 196 self.value_tag == CharacterStringTags.URI_SCHEME or \ 197 self.value_tag == CharacterStringTags.CHARSET or \ 198 self.value_tag == CharacterStringTags.NATURAL_LANGUAGE or \ 199 self.value_tag == CharacterStringTags.MIME_MEDIA_TYPE: 199 200 return (len(self.value), struct.pack('>%ss' % len(self.value), self.value)) 200 201
Note: See TracChangeset
for help on using the changeset viewer.