def run(filter=None): engine = create_engine(sccpreplay.DB_URL) metadata = MetaData(engine) tbl_packets = Table('packets', metadata, *model.packets_columns) tbl_messages = Table('messages', metadata, *model.messages_columns) tbl_session_counter = Table('session_counter', metadata, *model.session_counter_columns) metadata.create_all() tbl_messages.delete().execute() packets = tbl_packets.select().execute() messages = [] i = 1 j = 1 messages = [] message_factory = MessageFactory() channels_assemblers = defaultdict(MessageAssembler) for packet in packets: channel = (packet['session'], packet['side']) assembler = channels_assemblers[channel] packets_data = assembler.feed(packet.data) for packet_data in packets_data: # if packet_data[4] == '\x03': # print 'button' message = packet_to_message(dict(packet)) message['data'] = packet_data m = sccpclientprotocol.deserialize(packet_data, message_factory) message['type'] = m.sccpmessageType # print packet['number'], message['session'], message['side'], m, '%04X' % m.sccpmessageType messages.append(message) tbl_messages.insert().execute(messages)
def deserialize(self, packet_data): return sccpclientprotocol.deserialize(packet_data, self.message_factory)