Ejemplo n.º 1
0
def main():
    parser = argparse.ArgumentParser(
        description='Dump the contents of a pirate data file')
    parser.add_argument('log', metavar='LOG', type=argparse.FileType('r'),
                        help='Pirate log to analyze')

    args = parser.parse_args()

    try:
        header = pirate.read_header(args.log)
        print header
        for d in pirate.stream_dumps(args.log):
            print d
    except RuntimeError, e:
        print >> sys.stderr, "Failed to read pirate log: %s" % e
        sys.exit(2)
Ejemplo n.º 2
0
def main():
    parser = argparse.ArgumentParser(
        description='Dump the contents of a pirate data file')
    parser.add_argument('log',
                        metavar='LOG',
                        type=argparse.FileType('r'),
                        help='Pirate log to analyze')

    args = parser.parse_args()

    try:
        header = pirate.read_header(args.log)
        print header
        for d in pirate.stream_dumps(args.log):
            print d
    except RuntimeError, e:
        print >> sys.stderr, "Failed to read pirate log: %s" % e
        sys.exit(2)
Ejemplo n.º 3
0
def main():
    parser = argparse.ArgumentParser(
        description='Dump the contents of a pirate data file')
    parser.add_argument('log', metavar='LOG', type=argparse.FileType('r'),
                        help="Pirate log to analyze")

    parser.add_argument('--fs', metavar='FS', type=str, default=" ",
                        help="Output field separator")

    parser.add_argument('--no-header', action="store_true", default=False,
                        help="Don't include CSV header with field descriptions")

    parser.add_argument('--no-aggregate', action="store_true", default=False,
                        help="Don't sum counters")

    args = parser.parse_args()

    try:
        header = pirate.read_header(args.log)
        if not args.no_header:
            print_header(header)

        d_agg = {}
        for _d in pirate.stream_dumps(args.log):
            d = Dump(_d)
            if args.no_aggregate:
                d.print_csv(ofs=args.fs)
            elif d.size in d_agg:
                d_agg[d.size].add(d)
            else:
                d_agg[d.size] = d

        if not args.no_aggregate:
            sizes = d_agg.items()
            sizes.sort(key=lambda (size, dump): size)
            for size, dump in sizes:
                dump.print_csv(ofs=args.fs)
    except RuntimeError, e:
        print >> sys.stderr, "Failed to read pirate log: %s" % e
        sys.exit(2)