示例#1
0
文件: parse_dir.py 项目: rouge8/pig
    def _handle(self, *args, **options):
        pcap_dir = args[0]
        pcaps = os.listdir(pcap_dir)
        for pcap_file in pcaps:
            print "current file: ", pcap_dir+ pcap_file
            pcap = PacketReader(pcap_dir+pcap_file)

            for packet in pcap:
                p = Packet(**packet)
                p.save()

        transaction.commit()
示例#2
0
文件: parse_pcap.py 项目: rouge8/pig
    def _handle(self, *args, **options):
        pcap_file = args[0]
        print 'Parsing %s' %pcap_file
        pcap = PacketReader(pcap_file)

        try:
            for packet in pcap:
                p = Packet(**packet)
                p.save()
            transaction.commit()
            print '%s parsed successfully.' %pcap_file
        except IntegrityError:
            transaction.rollback()
            sys.stderr.write('ERROR: %s was already parsed.\n' %pcap_file)
        finally:
            print