- Timestamp:
- 09/03/05 00:47:48 (19 years ago)
- Location:
- tea4cups/trunk
- Files:
-
- 2 modified
Legend:
- Unmodified
- Added
- Removed
-
tea4cups/trunk/NEWS
r652 r653 23 23 Tea4CUPS News : 24 24 25 * 3.02 : 26 27 - Fixed some problems thanks to pychecker. 28 25 29 * 3.01 : 26 30 -
tea4cups/trunk/tea4cups
r652 r653 27 27 import os 28 28 import pwd 29 import popen230 29 import errno 31 30 import md5 … … 34 33 import tempfile 35 34 import ConfigParser 36 import select37 35 import signal 38 import time 39 from struct import unpack 40 41 version = "3.01_unofficial" 36 from struct import pack, unpack 37 38 version = "3.02_unofficial" 42 39 43 40 class TeeError(Exception): … … 183 180 return "" 184 181 else : 185 buffer = []186 buffer.append("IPP version : %s.%s" % self.version)187 buffer.append("IPP operation Id : 0x%04x" % self.operation_id)188 buffer.append("IPP request Id : 0x%08x" % self.request_id)182 mybuffer = [] 183 mybuffer.append("IPP version : %s.%s" % self.version) 184 mybuffer.append("IPP operation Id : 0x%04x" % self.operation_id) 185 mybuffer.append("IPP request Id : 0x%08x" % self.request_id) 189 186 for attrtype in self.attributes_types : 190 187 attrdict = getattr(self, "%s_attributes" % attrtype) 191 188 if attrdict : 192 buffer.append("%s attributes :" % attrtype.title())189 mybuffer.append("%s attributes :" % attrtype.title()) 193 190 for key in attrdict.keys() : 194 buffer.append(" %s : %s" % (key, attrdict[key]))191 mybuffer.append(" %s : %s" % (key, attrdict[key])) 195 192 if self.data : 196 buffer.append("IPP datas : %s" % repr(message.data))197 return "\n".join( buffer)193 mybuffer.append("IPP datas : %s" % repr(self.data)) 194 return "\n".join(mybuffer) 198 195 199 196 def dump(self) : … … 202 199 Returns the message as a string of text. 203 200 """ 204 buffer = []201 mybuffer = [] 205 202 if None not in (self.version, self.operation_id, self.request_id) : 206 buffer.append(chr(self.version[0]) + chr(self.version[1]))207 buffer.append(pack(">H", self.operation_id))208 buffer.append(pack(">I", self.request_id))203 mybuffer.append(chr(self.version[0]) + chr(self.version[1])) 204 mybuffer.append(pack(">H", self.operation_id)) 205 mybuffer.append(pack(">I", self.request_id)) 209 206 for attrtype in self.attributes_types : 210 207 tagprinted = 0 211 208 for (attrname, value) in getattr(self, "%s_attributes" % attrtype).items() : 212 209 if not tagprinted : 213 buffer.append(chr(self.dictags["%s-attributes-tag" % attrtype]))210 mybuffer.append(chr(self.dictags["%s-attributes-tag" % attrtype])) 214 211 tagprinted = 1 215 212 if type(value) != type([]) : 216 213 value = [ value ] 217 214 for (vtype, val) in value : 218 buffer.append(chr(self.dictags[vtype]))219 buffer.append(pack(">H", len(attrname)))220 buffer.append(attrname)215 mybuffer.append(chr(self.dictags[vtype])) 216 mybuffer.append(pack(">H", len(attrname))) 217 mybuffer.append(attrname) 221 218 if vtype in ("integer", "enum") : 222 buffer.append(pack(">H", 4))223 buffer.append(pack(">I", val))219 mybuffer.append(pack(">H", 4)) 220 mybuffer.append(pack(">I", val)) 224 221 elif vtype == "boolean" : 225 buffer.append(pack(">H", 1))226 buffer.append(chr(val))222 mybuffer.append(pack(">H", 1)) 223 mybuffer.append(chr(val)) 227 224 else : 228 buffer.append(pack(">H", len(val)))229 buffer.append(val)230 buffer.append(chr(self.dictags["end-of-attributes-tag"]))231 buffer.append(self.data)232 return "".join( buffer)225 mybuffer.append(pack(">H", len(val))) 226 mybuffer.append(val) 227 mybuffer.append(chr(self.dictags["end-of-attributes-tag"])) 228 mybuffer.append(self.data) 229 return "".join(mybuffer) 233 230 234 231 def parse(self) : … … 781 778 if pid == 0 : 782 779 if self.InputFile is None : 783 f = open(self. dataFile, "rb")780 f = open(self.DataFile, "rb") 784 781 os.dup2(f.fileno(), 0) 785 782 f.close()