Add flag for process command to force re-conversion of trace directory
This commit is contained in:
parent
459362bd53
commit
87ff5c245a
1 changed files with 33 additions and 13 deletions
|
@ -34,40 +34,60 @@ def parse_args():
|
||||||
'input_path',
|
'input_path',
|
||||||
help='the path to a converted file to import and process, '
|
help='the path to a converted file to import and process, '
|
||||||
'or the path to a CTF directory to convert 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()
|
return parser.parse_args()
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
args = parse_args()
|
args = parse_args()
|
||||||
input_path = args.input_path
|
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)
|
input_path = os.path.expanduser(input_path)
|
||||||
# Check if not a file
|
# Check if not a file
|
||||||
if not os.path.isfile(input_path):
|
if not os.path.isfile(input_path):
|
||||||
# Might be a trace directory
|
input_directory = input_path
|
||||||
# Check if there is a converted file
|
# Might be a (trace) directory
|
||||||
prospective_converted_file = os.path.join(input_path, DEFAULT_CONVERT_FILE_NAME)
|
# Check if there is a converted file under the given directory
|
||||||
if os.path.isfile(prospective_converted_file):
|
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
|
# Use that as the converted input file
|
||||||
print(f'found converted file: {prospective_converted_file}')
|
converted_file_path = prospective_converted_file_path
|
||||||
input_path = prospective_converted_file
|
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:
|
else:
|
||||||
# Check if it is a trace directory
|
# Check if it is a trace directory
|
||||||
# Result could be unexpected because it will look for trace directories recursively
|
# 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 trace directory first to create converted file
|
||||||
convert(input_path, DEFAULT_CONVERT_FILE_NAME)
|
convert(input_directory, DEFAULT_CONVERT_FILE_NAME)
|
||||||
input_path = prospective_converted_file
|
converted_file_path = prospective_converted_file_path
|
||||||
else:
|
else:
|
||||||
# We cannot do anything
|
# We cannot do anything
|
||||||
print(
|
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)
|
file=sys.stderr)
|
||||||
return 1
|
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)
|
||||||
|
|
||||||
events = load_file(input_path)
|
start_time = time.time()
|
||||||
|
|
||||||
|
events = load_file(converted_file_path)
|
||||||
ros2_handler = Ros2Handler.process(events)
|
ros2_handler = Ros2Handler.process(events)
|
||||||
|
|
||||||
time_diff = time.time() - start_time
|
time_diff = time.time() - start_time
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue