Commits (2)
......@@ -32,20 +32,27 @@ def parse_args():
help='the path to the main CTF trace directory')
'-o', '--output-file-path', dest='output_file_path',
help='the path to the output file to generate '
f'(default: $trace_directory/{DEFAULT_CONVERT_FILE_NAME})')
args = parser.parse_args()
if args.output_file_path is None:
args.output_file_path = os.path.join(args.trace_directory, DEFAULT_CONVERT_FILE_NAME)
return args
'-o', '--output-file-name', dest='output_file_name',
help='the name of the output file to generate, '
'under $trace_directory (default: %(default)s)')
return parser.parse_args()
def convert(
trace_directory: str,
output_file_path: str,
output_file_name: str = DEFAULT_CONVERT_FILE_NAME,
) -> None:
print(f'importing trace directory: {trace_directory}')
Convert trace directory to a file.
The output file will be placed under the trace directory.
:param trace_directory: the path to the trace directory to import
:param outout_file_name: the name of the output file
print(f'converting trace directory: {trace_directory}')
output_file_path = os.path.join(os.path.expanduser(trace_directory), output_file_name)
start_time = time.time()
count = ctf.convert(trace_directory, output_file_path)
time_diff = time.time() - start_time
......@@ -57,6 +64,6 @@ def main():
args = parse_args()
trace_directory = args.trace_directory
output_file_path = args.output_file_path
output_file_name = args.output_file_name
convert(trace_directory, output_file_path)
convert(trace_directory, output_file_name)
......@@ -32,7 +32,7 @@ def parse_args():
'directory and output model data.')
help='the path to a converted file to import, '
help='the path to a converted file to import and process, '
'or the path to a CTF directory to convert and process')
return parser.parse_args()
......@@ -43,6 +43,7 @@ def main():
start_time = time.time()
input_path = os.path.expanduser(input_path)
# Check if not a file
if not os.path.isfile(input_path):
# Might be a trace directory
......@@ -57,11 +58,13 @@ def main():
# Result could be unexpected because it will look for trace directories recursively
if is_trace_directory(input_path):
# Convert trace directory first to create converted file
convert(input_path, prospective_converted_file)
convert(input_path, DEFAULT_CONVERT_FILE_NAME)
input_path = prospective_converted_file
# We cannot do anything
print('cannot find either a trace directory or a converted file', file=sys.stderr)
f'cannot find either a trace directory or a converted file: {input_path}',
return 1
events = load_file(input_path)