diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2021-11-25 14:54:50 +0100 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2021-11-25 18:26:19 +0100 |
commit | 106b9c0871f6de63b78f2c59bcf16c21d60bb5a8 (patch) | |
tree | f3fc5c42a605389bddaf409f3f6251965c4fa761 /tools | |
parent | be6be51898186b85f955139328c600559e68cc6e (diff) |
debug_windows.py: Fix --help handling
Pass the unmodified arguments to the arguments in case help was requested.
Add the verbose description text as an epilog. Also display help when
invoked without administrative privileges.
Pick-to: 6.2
Change-Id: I1580afbda1455be6d4ddedc6390f4d6f24990b83
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/debug_windows.py | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/tools/debug_windows.py b/tools/debug_windows.py index de3ddf445..8ddbcebbb 100644 --- a/tools/debug_windows.py +++ b/tools/debug_windows.py @@ -37,7 +37,7 @@ ## ############### -""" +EPILOG = """ This is a troubleshooting script that assists finding out which DLLs or which symbols in a DLL are missing when executing a PySide6 python script. @@ -71,27 +71,24 @@ from os import path from textwrap import dedent is_win = sys.platform == "win32" -is_py_3 = sys.version_info[0] == 3 if is_win: - if is_py_3: - import winreg - else: - import _winreg as winreg - import exceptions + import winreg def get_parser_args(): desc_msg = "Run an executable under cdb with loader snaps set." help_msg = "Pass the executable and the arguments passed to it as a list." - parser = argparse.ArgumentParser(description=desc_msg) + parser = argparse.ArgumentParser(description=desc_msg, + formatter_class=argparse.RawDescriptionHelpFormatter, + epilog=EPILOG) parser.add_argument('args', nargs='*', help=help_msg) # Prepend -- so that python options like '-c' are ignored by # argparse. - massaged_args = ['--'] + sys.argv[1:] - return parser.parse_args(massaged_args) + help_requested = '-h' in sys.argv or '--help' in sys.argv + massaged_args = ['--'] + sys.argv[1:] if not help_requested else sys.argv + return parser, parser.parse_args(massaged_args) -parser_args = get_parser_args() verbose_log_file_name = path.join(path.dirname(path.abspath(__file__)), 'log_debug_windows.txt') @@ -342,7 +339,7 @@ print(">>>>>>>>>>>>>>>>>>>>>>> QtCore object instance: {}".format(PySide6.QtCore call_command_under_cdb_with_gflags(sys.executable, ["-c", python_code]) -def handle_args(): +def handle_args(parser_args): if not parser_args.args: test_run_import_qt_core_under_cdb_with_gflags() else: @@ -355,9 +352,12 @@ if __name__ == '__main__': log.error("This script only works on Windows.") exit(1) + parser, parser_args = get_parser_args() + if is_admin(): - handle_args() + handle_args(parser_args) else: log.error("Please rerun the script with administrator privileges. " "It is required for gflags.exe to work. ") + parser.print_help() exit(1) |