From 9020563fc8bfb2b5abf929f45be1c046ddd8d785 Mon Sep 17 00:00:00 2001 From: Frank Busse Date: Wed, 15 Mar 2023 10:28:44 +0000 Subject: klee-stats: improve error message for missing tabulate package --- tools/klee-stats/klee-stats | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) (limited to 'tools') diff --git a/tools/klee-stats/klee-stats b/tools/klee-stats/klee-stats index b3673c7e..22cdaf43 100755 --- a/tools/klee-stats/klee-stats +++ b/tools/klee-stats/klee-stats @@ -464,10 +464,16 @@ def main(): parser.add_argument('dir', nargs='+', help='KLEE output directory') if tabulate_available: - parser.add_argument('--table-format', - choices=['klee', 'csv', 'readable-csv'] + list(_table_formats.keys()), - dest='tableFormat', default='klee', - help='Table format for the summary.') + tf_choices = ['klee', 'csv', 'readable-csv'] + list(_table_formats.keys()) + tf_help = 'Table format for the summary.' + tf_default = 'klee' + else: + tf_choices = [] + tf_help = '(not available due to missing "tabulate" package)' + tf_default = None + parser.add_argument('--table-format', + choices=tf_choices, dest='tableFormat', default=tf_default, + help=tf_help) parser.add_argument('--to-csv', action='store_true', dest='toCsv', @@ -506,6 +512,13 @@ def main(): args = parser.parse_args() + if not tabulate_available and not (args.grafana or args.toCsv): + print('Error: Package "tabulate" required for table formatting. ' + 'Please install it using "pip" or your package manager. ' + 'You can still use --grafana and --to-csv without tabulate.', + file=sys.stderr) + sys.exit(1) + # get print controls pr = 'NONE' if args.pAll or args.columns: @@ -539,16 +552,7 @@ def main(): write_csv(data) return - if tabulate_available: - write_table(args, data, dirs, pr) - return - - print('Error: Package "tabulate" required for table formatting. ' - 'Please install it using "pip" or your package manager.' - 'You can still use --grafana and --to-csv without tabulate.', - file=sys.stderr) - sys.exit(1) - + write_table(args, data, dirs, pr) if __name__ == '__main__': -- cgit 1.4.1