Browse Source

gw.py: Add a secret argument to force backtrace on error.

Keir Fraser 4 years ago
parent
commit
ccb2182529
1 changed files with 7 additions and 1 deletions
  1. 7 1
      scripts/gw.py

+ 7 - 1
scripts/gw.py

@@ -48,6 +48,11 @@ actions = [ 'info',
             'bandwidth' ]
 argv = sys.argv
 
+backtrace = False
+if len(argv) > 1 and argv[1] == '--bt':
+    backtrace = True
+    argv = [argv[0]] + argv[2:]
+
 if len(argv) < 2 or argv[1] not in actions:
     print("Usage: %s [action] [-h] ..." % (argv[0]))
     print("  -h, --help  Show help message for specified action")
@@ -63,9 +68,10 @@ try:
     res = main(argv)
     if res is None:
         res = 0
-except (IndexError, AssertionError):
+except (IndexError, AssertionError, TypeError, KeyError):
     raise
 except Exception as err:
+    if backtrace: raise
     print("** FATAL ERROR:")
     print(err)
     res = 1