def managed_output_trace(in_uri):
    trace = plt.output_trace(in_uri)
    trace.start_output()
    try:
        yield trace
    finally:
        trace.close_output()
Пример #2
0
import sys     #  argv, exit

in_uri = sys.argv[1]  # Program name is argv[0]
out_uri = sys.argv[2]
n_records = sys.argv[3]
if not n_records or int(n_records) <= 0:
    print "Number of records to copy not specified <<<"
    exit()
else:
    n_records = int(n_records)
    print "copying first %d records from %s to %s ..." % (
        n_records, in_uri, out_uri)

t = plt.trace(in_uri)
t.start()

ot = plt.output_trace(out_uri)
ot.start_output()

n = 0
for pkt in t:
    n += 1

    ot.write_packet(pkt)

    if n == n_records:
        break

ot.close_output();  t.close()
Пример #3
0
import plt  # Also imports IPprefix and datetime

import sys  #  argv, exit
from plt_testing import *

in_uri = 'icmp-sample.pcap'
out_uri = 'pcapfile:icmp-sample-out.pcap'
n_records = 10
test_println(
    "copying first %d records from %s to %s ..." %
    (n_records, in_uri, out_uri), get_tag())

t = plt.trace(in_uri)
t.start()

ot = plt.output_trace(out_uri)
ot.start_output()

n = 0
for pkt in t:
    n += 1

    ot.write_packet(pkt)

    if n == n_records:
        break

if n != n_records:
    test_println(
        "error copying records. only %d out of %d were copied." %
        (n, n_records), get_tag())