def readData(self, rawstring, datatype): """Read the data part of the message coming from stream Arguments: rawstring -- raw data bytes datatype -- data type Return value: the data read """ data = rawstring[:-1] #remove last NULL byte if datatype == ERROR: return data elif datatype == STRING or datatype == DOUBLE: # try to convert data to a more appropriate type try: data = int(data) except: try: data = float(data) except: pass return data elif datatype == ASSOC: return rawtodictonary(rawstring) elif SpecArray.isArrayType(datatype): #Here we read cols and rows... which are *supposed* to be received in the header!!! #better approach: data contains this information (since it is particular to that data type) return SpecArray.SpecArray(rawstring, datatype, self.rows, self.cols) else: raise TypeError