Use argparse for tracetools_analysis entrypoints
This commit is contained in:
parent
e5b8d1782f
commit
3ea4a1c5bb
2 changed files with 17 additions and 13 deletions
|
@ -2,19 +2,22 @@
|
||||||
# Entrypoint/script to convert CTF trace data to a pickle file
|
# Entrypoint/script to convert CTF trace data to a pickle file
|
||||||
# TODO
|
# TODO
|
||||||
|
|
||||||
|
import argparse
|
||||||
from pickle import Pickler
|
from pickle import Pickler
|
||||||
import sys
|
|
||||||
|
|
||||||
from tracetools_analysis.conversion import ctf
|
from tracetools_analysis.conversion import ctf
|
||||||
|
|
||||||
|
|
||||||
def main(argv=sys.argv):
|
def main():
|
||||||
if len(argv) != 3:
|
parser = argparse.ArgumentParser(description='Convert CTF trace data to a pickle file.')
|
||||||
print('usage: /trace/directory pickle_target_file')
|
parser.add_argument('trace_directory',
|
||||||
exit(1)
|
help='the path to the main CTF trace directory')
|
||||||
|
parser.add_argument('pickle_file',
|
||||||
|
help='the target pickle file to generate')
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
trace_directory = sys.argv[1]
|
trace_directory = args.trace_directory
|
||||||
pickle_target_file = sys.argv[2]
|
pickle_target_file = args.pickle_file
|
||||||
|
|
||||||
with open(pickle_target_file, 'wb') as f:
|
with open(pickle_target_file, 'wb') as f:
|
||||||
p = Pickler(f, protocol=4)
|
p = Pickler(f, protocol=4)
|
||||||
|
|
|
@ -1,18 +1,19 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
# Entrypoint/script to process events from a pickle file to build a ROS model
|
# Entrypoint/script to process events from a pickle file to build a ROS model
|
||||||
|
|
||||||
|
import argparse
|
||||||
import pickle
|
import pickle
|
||||||
import sys
|
|
||||||
|
|
||||||
from tracetools_analysis.analysis import ros_processor, to_pandas
|
from tracetools_analysis.analysis import ros_processor, to_pandas
|
||||||
|
|
||||||
|
|
||||||
def main(argv=sys.argv):
|
def main():
|
||||||
if len(argv) != 2:
|
parser = argparse.ArgumentParser(description='Process a pickle file generated from tracing and analyze the data.')
|
||||||
print('usage: pickle_file')
|
parser.add_argument('pickle_file',
|
||||||
exit(1)
|
help='the pickle file to import')
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
pickle_filename = sys.argv[1]
|
pickle_filename = args.pickle_file
|
||||||
with open(pickle_filename, 'rb') as f:
|
with open(pickle_filename, 'rb') as f:
|
||||||
events = _get_events_from_pickled_file(f)
|
events = _get_events_from_pickled_file(f)
|
||||||
print(f'imported {len(events)} events')
|
print(f'imported {len(events)} events')
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue