class IterClassFile(object): """ Wrapper class to iterate over packets from psocket """ def __init__(self): self.reader = Reader(filename="../tests/packets_ether.pcap", lowest_layer=ethernet.Ethernet) def __iter__(self): while True: # time.sleep(0.5) try: # print("reading next....") pkt = self.reader.__next__()[1] if type(pkt) is bytes: print("only bytes..") continue yield pkt except StopIteration: break except: continue self.reader.close()
def __init__(self): self.reader = Reader(filename="../tests/packets_ether.pcap", lowest_layer=ethernet.Ethernet)