def serialize(self): stream = samples_pb2.sample_stream() stream.timestamp = self.timestamp stream.session_id = self.session_id.bytes stream.machine_id = str(bytearray(self.machine_id)) stream.channel = self.channel stream.samples.extend(self.samples) return stream.SerializeToString()
def deserialize(serialized): stream = samples_pb2.sample_stream() stream.ParseFromString(serialized) # text_format.Merge(serialized, stream) b = Block() b.timestamp = stream.timestamp b.channel = stream.channel b.samples = stream.samples return b