Merge commit 'f31aead992e829cb15c4fbedbf816a23d2a916a7' into jswz72/master

This commit is contained in:
Florian Bruhin 2017-04-11 21:17:49 +02:00
commit b966034250
3 changed files with 22 additions and 7 deletions

View File

@ -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)

View File

@ -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:

View File

@ -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 "
@ -118,6 +114,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, 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 "
"startup.", metavar=':command')
# URLs will actually be in command
@ -145,6 +144,22 @@ def logfilter_error(logfilter: str):
logfilter, ', '.join(log.LOGGER_NAMES)))
def debug_flag_error(flag):
"""Validate flags passed to --debug-flag.
Available flags:
debug-exit: Turn on debugging of late exit.
pdb-postmortem: Drop into pdb on exceptions.
"""
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()
if sys.platform == 'darwin' and getattr(sys, 'frozen', False):