From 3b87e7c2972f24f4391b3c5f4c3ff9212f3bbade Mon Sep 17 00:00:00 2001 From: Jacob Sword Date: Fri, 7 Apr 2017 21:12:42 -0400 Subject: [PATCH 1/7] Add --debug-exit argument and validity check --- qutebrowser/qutebrowser.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/qutebrowser/qutebrowser.py b/qutebrowser/qutebrowser.py index 8321fb04b..aaf86850f 100644 --- a/qutebrowser/qutebrowser.py +++ b/qutebrowser/qutebrowser.py @@ -118,6 +118,9 @@ def get_argparser(): action='append') debug.add_argument('--qt-flag', help="Pass an argument to Qt as flag.", nargs=1, action='append') + debug.add_argument('--debug-flag', type=debug_flag_error, + help="Pass name of debugging feature to be turned on.", + nargs=1, action='append') parser.add_argument('command', nargs='*', help="Commands to execute on " "startup.", metavar=':command') # URLs will actually be in command @@ -144,6 +147,21 @@ def logfilter_error(logfilter: str): "filters: Invalid value {} - expected a list of: {}".format( logfilter, ', '.join(log.LOGGER_NAMES))) +def debug_flag_error(flag): + """Validate flags passed to --debug-flag. + + Available flags: + debug-exit + pdb-postmortem + """ + valid_flags = ['debug-exit','pdb-postmortem'] + + if flag in valid_flags: + return flag + else: + raise argparse.ArgumentTypeError("Invalid flag - valid flags include: " + + str(valid_flags)) + def main(): parser = get_argparser() From 45dff6c0c81effecb05e6d2a88096d357a0bc736 Mon Sep 17 00:00:00 2001 From: Jacob Sword Date: Sat, 8 Apr 2017 16:54:08 -0400 Subject: [PATCH 2/7] update usage of debug-flag arguments --- qutebrowser/app.py | 2 +- qutebrowser/misc/crashsignal.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/qutebrowser/app.py b/qutebrowser/app.py index 81079104a..086c67528 100644 --- a/qutebrowser/app.py +++ b/qutebrowser/app.py @@ -792,7 +792,7 @@ class Application(QApplication): def exit(self, status): """Extend QApplication::exit to log the event.""" log.destroy.debug("Now calling QApplication::exit.") - if self._args.debug_exit: + if 'debug_exit' in self._args.debug_flags: if hunter is None: print("Not logging late shutdown because hunter could not be " "imported!", file=sys.stderr) diff --git a/qutebrowser/misc/crashsignal.py b/qutebrowser/misc/crashsignal.py index aa7438732..d8d8bb385 100644 --- a/qutebrowser/misc/crashsignal.py +++ b/qutebrowser/misc/crashsignal.py @@ -207,10 +207,10 @@ class CrashHandler(QObject): is_ignored_exception = (exctype is bdb.BdbQuit or not issubclass(exctype, Exception)) - if self._args.pdb_postmortem: + if 'pdb-postmortem' in self._args.debug_flags: pdb.post_mortem(tb) - if is_ignored_exception or self._args.pdb_postmortem: + if is_ignored_exception or 'pdb-postmortem' in self._args.debug_flags: # pdb exit, KeyboardInterrupt, ... status = 0 if is_ignored_exception else 2 try: From 6ccb42023050287f7b16404556e2dc07386cebf5 Mon Sep 17 00:00:00 2001 From: Jacob Sword Date: Sat, 8 Apr 2017 18:42:26 -0400 Subject: [PATCH 3/7] Fix syntax error in debug-exit --- qutebrowser/app.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qutebrowser/app.py b/qutebrowser/app.py index 086c67528..8ca322078 100644 --- a/qutebrowser/app.py +++ b/qutebrowser/app.py @@ -792,7 +792,7 @@ class Application(QApplication): def exit(self, status): """Extend QApplication::exit to log the event.""" log.destroy.debug("Now calling QApplication::exit.") - if 'debug_exit' in self._args.debug_flags: + if 'debug-exit' in self._args.debug_flags: if hunter is None: print("Not logging late shutdown because hunter could not be " "imported!", file=sys.stderr) From 7588cdb1856d7cada79f4dbbe99f6495838f1a8d Mon Sep 17 00:00:00 2001 From: Jacob Sword Date: Sat, 8 Apr 2017 19:04:25 -0400 Subject: [PATCH 4/7] fixed formatting issues --- qutebrowser/qutebrowser.py | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/qutebrowser/qutebrowser.py b/qutebrowser/qutebrowser.py index aaf86850f..4019b9650 100644 --- a/qutebrowser/qutebrowser.py +++ b/qutebrowser/qutebrowser.py @@ -118,9 +118,9 @@ def get_argparser(): action='append') debug.add_argument('--qt-flag', help="Pass an argument to Qt as flag.", nargs=1, action='append') - debug.add_argument('--debug-flag', type=debug_flag_error, - help="Pass name of debugging feature to be turned on.", - nargs=1, action='append') + debug.add_argument('--debug-flag', type=debug_flag_error, + help="Pass name of debugging feature to be turned on.", + nargs=1, action='append') parser.add_argument('command', nargs='*', help="Commands to execute on " "startup.", metavar=':command') # URLs will actually be in command @@ -147,21 +147,22 @@ def logfilter_error(logfilter: str): "filters: Invalid value {} - expected a list of: {}".format( logfilter, ', '.join(log.LOGGER_NAMES))) + def debug_flag_error(flag): """Validate flags passed to --debug-flag. - Available flags: - debug-exit - pdb-postmortem - """ - valid_flags = ['debug-exit','pdb-postmortem'] + Available flags: + debug-exit + pdb-postmortem + """ + valid_flags = ['debug-exit', 'pdb-postmortem'] - if flag in valid_flags: - return flag + if flag in valid_flags: + return flag else: - raise argparse.ArgumentTypeError("Invalid flag - valid flags include: " + - str(valid_flags)) - + raise argparse.ArgumentTypeError("Invalid flag - valid flags include: " + + str(valid_flags)) + def main(): parser = get_argparser() From c0ac1bd79a82d6abeaa8b0fa38035f89f9993768 Mon Sep 17 00:00:00 2001 From: Jacob Sword Date: Sun, 9 Apr 2017 10:34:51 -0500 Subject: [PATCH 5/7] Add 'dest' for '--debug-flag' --- qutebrowser/qutebrowser.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qutebrowser/qutebrowser.py b/qutebrowser/qutebrowser.py index 4019b9650..e318cc2e4 100644 --- a/qutebrowser/qutebrowser.py +++ b/qutebrowser/qutebrowser.py @@ -120,7 +120,7 @@ def get_argparser(): nargs=1, action='append') debug.add_argument('--debug-flag', type=debug_flag_error, help="Pass name of debugging feature to be turned on.", - nargs=1, action='append') + nargs=1, action='append', dest='debug_flags') parser.add_argument('command', nargs='*', help="Commands to execute on " "startup.", metavar=':command') # URLs will actually be in command From dcf8f29a6765fea0f94f580dfa37067431a0e1a5 Mon Sep 17 00:00:00 2001 From: Jacob Sword Date: Sun, 9 Apr 2017 10:43:40 -0500 Subject: [PATCH 6/7] Remove old --pdb-postmortem and --debug-exit flags --- qutebrowser/qutebrowser.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/qutebrowser/qutebrowser.py b/qutebrowser/qutebrowser.py index e318cc2e4..98bb681ef 100644 --- a/qutebrowser/qutebrowser.py +++ b/qutebrowser/qutebrowser.py @@ -103,10 +103,6 @@ def get_argparser(): help="Silently remove unknown config options.") debug.add_argument('--nowindow', action='store_true', help="Don't show " "the main window.") - debug.add_argument('--debug-exit', help="Turn on debugging of late exit.", - action='store_true') - debug.add_argument('--pdb-postmortem', action='store_true', - help="Drop into pdb on exceptions.") debug.add_argument('--temp-basedir', action='store_true', help="Use a " "temporary basedir.") debug.add_argument('--no-err-windows', action='store_true', help="Don't " @@ -152,8 +148,8 @@ def debug_flag_error(flag): """Validate flags passed to --debug-flag. Available flags: - debug-exit - pdb-postmortem + debug-exit: Turn on debugging of late exit. + pdb-postmortem: Drop into pdb on exceptions. """ valid_flags = ['debug-exit', 'pdb-postmortem'] From f31aead992e829cb15c4fbedbf816a23d2a916a7 Mon Sep 17 00:00:00 2001 From: Jacob Sword Date: Sun, 9 Apr 2017 23:34:33 -0400 Subject: [PATCH 7/7] Add default to --debug-flag --- qutebrowser/qutebrowser.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qutebrowser/qutebrowser.py b/qutebrowser/qutebrowser.py index 98bb681ef..3ce11b07b 100644 --- a/qutebrowser/qutebrowser.py +++ b/qutebrowser/qutebrowser.py @@ -114,7 +114,7 @@ def get_argparser(): action='append') debug.add_argument('--qt-flag', help="Pass an argument to Qt as flag.", nargs=1, action='append') - debug.add_argument('--debug-flag', type=debug_flag_error, + debug.add_argument('--debug-flag', type=debug_flag_error, default=[], help="Pass name of debugging feature to be turned on.", nargs=1, action='append', dest='debug_flags') parser.add_argument('command', nargs='*', help="Commands to execute on "