Add basic events processing entrypoint
This commit is contained in:
parent
9e217e0c56
commit
d1ea1bd9bd
2 changed files with 32 additions and 0 deletions
5
conversion/ros.py
Normal file
5
conversion/ros.py
Normal file
|
@ -0,0 +1,5 @@
|
|||
# Process trace events and create ROS model
|
||||
|
||||
def ros_import(events):
|
||||
for event in events:
|
||||
print(f'event: {str(event)}')
|
27
process.py
Normal file
27
process.py
Normal file
|
@ -0,0 +1,27 @@
|
|||
#!/usr/bin/env python3
|
||||
# Entrypoint/script to process events from a pickle file to build a ROS model
|
||||
|
||||
import sys
|
||||
import pickle
|
||||
from tracetools_analysis.conversion.ros import *
|
||||
|
||||
def main(argv=sys.argv):
|
||||
if len(argv) != 2:
|
||||
print('usage: pickle_file')
|
||||
exit(1)
|
||||
|
||||
pickle_filename = sys.argv[1]
|
||||
with open(pickle_filename, 'rb') as f:
|
||||
events = _get_events_from_pickled_file(f)
|
||||
print(f'imported {len(events)} events')
|
||||
ros_import(events)
|
||||
|
||||
def _get_events_from_pickled_file(file):
|
||||
p = pickle.Unpickler(file)
|
||||
events = []
|
||||
while True:
|
||||
try:
|
||||
events.append(p.load())
|
||||
except EOFError as _:
|
||||
break # we're done
|
||||
return events
|
Loading…
Add table
Add a link
Reference in a new issue