about summary refs log tree commit diff homepage
path: root/tools
diff options
context:
space:
mode:
authorFrank Busse <bb0xfb@gmail.com>2023-03-15 10:28:44 +0000
committerCristian Cadar <c.cadar@imperial.ac.uk>2023-03-22 17:31:32 +0000
commit9020563fc8bfb2b5abf929f45be1c046ddd8d785 (patch)
tree43e722dc9c18eea6a21e148ce0eb4cf730409c4f /tools
parent61d12516648cdb76e3a0b45e4fda74e9bf19b0a2 (diff)
downloadklee-9020563fc8bfb2b5abf929f45be1c046ddd8d785.tar.gz
klee-stats: improve error message for missing tabulate package
Diffstat (limited to 'tools')
-rwxr-xr-xtools/klee-stats/klee-stats32
1 files changed, 18 insertions, 14 deletions
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__':