Validate convert/process paths

Signed-off-by: Christophe Bedard <bedard.christophe@gmail.com>
This commit is contained in:
Christophe Bedard 2020-03-07 17:03:00 -05:00
parent 8d94dcf97e
commit 7488245fc2
2 changed files with 14 additions and 1 deletions

View file

@ -17,6 +17,7 @@
import argparse
import os
import sys
import time
from typing import Optional
@ -58,8 +59,13 @@ def convert(
:param trace_directory: the path to the trace directory to import
:param outout_file_name: the name of the output file
"""
trace_directory = os.path.expanduser(trace_directory)
if not os.path.isdir(trace_directory):
print(f'trace directory does not exist: {trace_directory}', file=sys.stderr)
return 1
print(f'converting trace directory: {trace_directory}')
output_file_path = os.path.join(os.path.expanduser(trace_directory), output_file_name)
output_file_path = os.path.join(trace_directory, output_file_name)
start_time = time.time()
count = ctf.convert(trace_directory, output_file_path)
time_diff = time.time() - start_time

View file

@ -16,6 +16,8 @@
"""Entrypoint/script to process events from a converted file to build a ROS model."""
import argparse
import os
import sys
import time
from typing import Optional
@ -60,6 +62,11 @@ def process(
:param force_conversion: whether to re-creating converted file even if it is found
:param hide_results: whether to hide results and not print them
"""
input_path = os.path.expanduser(input_path)
if not os.path.exists(input_path):
print(f'input path does not exist: {input_path}', file=sys.stderr)
return 1
start_time = time.time()
events = load_file(input_path, do_convert_if_needed=True, force_conversion=force_conversion)