forked from atheurer/trafficgen
-
Notifications
You must be signed in to change notification settings - Fork 1
/
postprocess-trex-profiler.py
executable file
·51 lines (39 loc) · 1.27 KB
/
postprocess-trex-profiler.py
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
#!/bin/python
from __future__ import print_function
import argparse
import os
import os.path
from trex_tg_lib import *
class t_global(object):
args = None
def process_options ():
parser = argparse.ArgumentParser(usage="postprocess a TRex profile")
parser.add_argument('--input',
dest = 'input_file',
help = 'Data file to process',
default = '',
type = str
)
t_global.args = parser.parse_args()
if len(t_global.args.input_file) == 0:
print(error("You must specify an input file"))
return(1)
elif not os.path.isfile(t_global.args.input_file):
print(error("You must specify a valid input file (not %s)" % (t_global.args.input_file)))
return(1)
elif not os.access(t_global.args.input_file, os.R_OK):
print(error("You must specify an input file that I have read access to"))
return(1)
return(0)
def main ():
ret_val = process_options()
if ret_val:
return(ret_val)
ret_val = trex_profiler_postprocess_file(t_global.args.input_file)
if ret_val:
print(dump_json_readable(ret_val))
else:
return(1)
return(0)
if __name__ == "__main__":
exit(main())