File: debugStats.py

package info (click to toggle)
norm 1.5.9%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye
  • size: 9,664 kB
  • sloc: cpp: 123,494; xml: 7,536; tcl: 5,460; makefile: 3,441; python: 1,898; java: 1,750; ansic: 642; sh: 21; csh: 8
file content (64 lines) | stat: -rwxr-xr-x 1,415 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/usr/bin/env python
'''
Example of live plotting of pipe logging data.
This has some problems still...
'''

import sys
import Queue
from optparse import OptionParser

import Gnuplot

# Include the local pynorm in the module search path
sys.path.insert(0, "../")
from pynorm.extra.pipeparser import PipeParser

USAGE = 'usage: %s [options]' % sys.argv[0]
DEFAULT_PIPE = 'normtest'

def get_option_parser():
    parser = OptionParser(usage=USAGE)
    parser.set_defaults(pipe=DEFAULT_PIPE)

    parser.add_option('-p', '--pipe',
            help='The pipe to connect to (default %s)' % DEFAULT_PIPE)
    return parser

def main(argv):
    (opts, args) = get_option_parser().parse_args(argv)

    if len(args) != 1:
        print USAGE
        return 1

    pipep = PipeParser(opts.pipe)
    pipep.start()

    g = Gnuplot.Gnuplot()
    g('set data style lines')
    g.title('FEC Buffer Usage')
    g.xlabel('Time (s)')
    g.ylabel('FEC Usage')

    ydata = []
    while True:
        try:
            report = pipep.reports.get(False)
        except Queue.Empty:
            continue
        try:
            ydata.append(report['remote'][0]['fec_cur'])
            g.plot(list(enumerate(ydata)))
        except IndexError:
            continue
        pipep.reports.task_done()
    print "Exiting..."
#    g.reset()
#    g.close()
#    del g

    return 0

if __name__ == '__main__':
    sys.exit(main(sys.argv))