| sys.path.append('../../../target/gen-py') |
| from packetstreamer import PacketStreamer |
| from packetstreamer.ttypes import * |
| from thrift import Thrift |
| from thrift.transport import TSocket |
| from thrift.transport import TTransport |
| from thrift.protocol import TBinaryProtocol |
| transport = TSocket.TSocket('localhost', 9090) |
| # Buffering is critical. Raw sockets are very slow |
| transport = TTransport.TFramedTransport(transport) |
| protocol = TBinaryProtocol.TBinaryProtocol(transport) |
| # Create a client to use the protocol encoder |
| client = PacketStreamer.Client(protocol) |
| packets = client.getPackets("session1") |
| print 'session1 packets num: %d' % (len(packets)) |
| print "Packet %d: %s"% (count, packet) |
| if "FilterTimeout" in packet: |
| except Thrift.TException, tx: |
| print '%s' % (tx.message) |
| except KeyboardInterrupt, e: |