Commit 87ff5c24 authored by Christophe Bedard's avatar Christophe Bedard

Add flag for process command to force re-conversion of trace directory

parent 459362bd
Pipeline #88452687 passed with stage
in 3 minutes and 17 seconds
......@@ -34,40 +34,60 @@ def parse_args():
'input_path',
help='the path to a converted file to import and process, '
'or the path to a CTF directory to convert and process')
parser.add_argument(
'-f', '--force-conversion', dest='force_conversion',
action='store_true', default=False,
help='re-convert trace directory even if converted file is found')
return parser.parse_args()
def main():
args = parse_args()
input_path = args.input_path
force_conversion = args.force_conversion
start_time = time.time()
converted_file_path = None
input_path = os.path.expanduser(input_path)
# Check if not a file
if not os.path.isfile(input_path):
# Might be a trace directory
# Check if there is a converted file
prospective_converted_file = os.path.join(input_path, DEFAULT_CONVERT_FILE_NAME)
if os.path.isfile(prospective_converted_file):
input_directory = input_path
# Might be a (trace) directory
# Check if there is a converted file under the given directory
prospective_converted_file_path = os.path.join(input_directory, DEFAULT_CONVERT_FILE_NAME)
if os.path.isfile(prospective_converted_file_path):
# Use that as the converted input file
print(f'found converted file: {prospective_converted_file}')
input_path = prospective_converted_file
converted_file_path = prospective_converted_file_path
if force_conversion:
print(f'found converted file but re-creating it: {converted_file_path}')
convert(input_directory, DEFAULT_CONVERT_FILE_NAME)
else:
print(f'found converted file: {converted_file_path}')
else:
# Check if it is a trace directory
# Result could be unexpected because it will look for trace directories recursively
if is_trace_directory(input_path):
# (e.g. '/' is a valid trace directory if there is at least one trace anywhere)
if is_trace_directory(input_directory):
# Convert trace directory first to create converted file
convert(input_path, DEFAULT_CONVERT_FILE_NAME)
input_path = prospective_converted_file
convert(input_directory, DEFAULT_CONVERT_FILE_NAME)
converted_file_path = prospective_converted_file_path
else:
# We cannot do anything
print(
f'cannot find either a trace directory or a converted file: {input_path}',
f'cannot find either a trace directory or a converted file: {input_directory}',
file=sys.stderr)
return 1
else:
converted_file_path = input_path
if force_conversion:
# It's a file, but re-create it anyway
print(f'found converted file but re-creating it: {converted_file_path}')
input_directory = os.path.dirname(converted_file_path)
input_file_name = os.path.basename(converted_file_path)
convert(input_directory, input_file_name)
start_time = time.time()
events = load_file(input_path)
events = load_file(converted_file_path)
ros2_handler = Ros2Handler.process(events)
time_diff = time.time() - start_time
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment