From b20db3b8a79c3e4e3421b1882fa80964726bdb4b Mon Sep 17 00:00:00 2001 From: Ulf Magnusson Date: Sun, 27 May 2018 16:00:29 +0200 Subject: Simplify error exits Had missed sys.exit(msg). --- examples/eval_expr.py | 3 +-- examples/find_symbol.py | 6 ++---- examples/help_grep.py | 3 +-- examples/merge_config.py | 3 +-- examples/oldconfig.py | 6 ++---- examples/print_sym_info.py | 3 +-- menuconfig.py | 3 +-- testsuite.py | 3 +-- 8 files changed, 10 insertions(+), 20 deletions(-) diff --git a/examples/eval_expr.py b/examples/eval_expr.py index 14231f9..6d8695e 100644 --- a/examples/eval_expr.py +++ b/examples/eval_expr.py @@ -10,8 +10,7 @@ import kconfiglib import sys if len(sys.argv) < 3: - print("Pass the expression to evaluate with SCRIPT_ARG=") - sys.exit(1) + sys.exit("Pass the expression to evaluate with SCRIPT_ARG=") expr = sys.argv[2] diff --git a/examples/find_symbol.py b/examples/find_symbol.py index b490e4d..55e6345 100644 --- a/examples/find_symbol.py +++ b/examples/find_symbol.py @@ -171,8 +171,7 @@ def nodes_referencing_sym(node, sym_name): # imported if __name__ == "__main__": if len(sys.argv) < 3: - print('Pass symbol name (without "CONFIG_" prefix) with SCRIPT_ARG=') - sys.exit(1) + sys.exit('Pass symbol name (without "CONFIG_" prefix) with SCRIPT_ARG=') sym_name = sys.argv[2] @@ -180,8 +179,7 @@ if __name__ == "__main__": nodes = nodes_referencing_sym(kconf.top_node, sym_name) if not nodes: - print("No reference to '{}' found".format(sym_name)) - sys.exit() + sys.exit("No reference to '{}' found".format(sym_name)) print("Found {} locations that reference '{}':\n".format(len(nodes), sym_name)) diff --git a/examples/help_grep.py b/examples/help_grep.py index a476d9c..20a4911 100644 --- a/examples/help_grep.py +++ b/examples/help_grep.py @@ -38,8 +38,7 @@ import re import sys if len(sys.argv) < 3: - print("Pass the regex with SCRIPT_ARG=") - sys.exit(1) + sys.exit("Pass the regex with SCRIPT_ARG=") search = re.compile(sys.argv[2], re.IGNORECASE).search diff --git a/examples/merge_config.py b/examples/merge_config.py index a51738c..f3fa471 100644 --- a/examples/merge_config.py +++ b/examples/merge_config.py @@ -63,8 +63,7 @@ from kconfiglib import Kconfig, Symbol, BOOL, TRISTATE, TRI_TO_STR import sys if len(sys.argv) < 4: - print("usage: merge_config.py Kconfig merged_config config1 [config2 ...]") - sys.exit(1) + sys.exit("usage: merge_config.py Kconfig merged_config config1 [config2 ...]") kconf = Kconfig(sys.argv[1]) diff --git a/examples/oldconfig.py b/examples/oldconfig.py index 722c9e4..4f8421a 100644 --- a/examples/oldconfig.py +++ b/examples/oldconfig.py @@ -317,12 +317,10 @@ def do_oldconfig_rec(node): if __name__ == "__main__": if len(sys.argv) != 2: - eprint("error: pass name of base Kconfig file as argument") - sys.exit(1) + sys.exit("error: pass name of base Kconfig file as argument") if not os.path.exists(".config"): - eprint("error: no existing .config") - sys.exit(1) + sys.exit("error: no existing .config") kconf = Kconfig(sys.argv[1]) diff --git a/examples/print_sym_info.py b/examples/print_sym_info.py index 3ee3c97..c0c63df 100644 --- a/examples/print_sym_info.py +++ b/examples/print_sym_info.py @@ -37,8 +37,7 @@ from kconfiglib import Kconfig, TRI_TO_STR import sys if len(sys.argv) < 3: - print('Pass symbol name (without "CONFIG_" prefix) with SCRIPT_ARG=') - sys.exit(1) + sys.exit('Pass symbol name (without "CONFIG_" prefix) with SCRIPT_ARG=') kconf = Kconfig(sys.argv[1]) sym = kconf.syms[sys.argv[2]] diff --git a/menuconfig.py b/menuconfig.py index 15a8539..781654c 100755 --- a/menuconfig.py +++ b/menuconfig.py @@ -283,8 +283,7 @@ _expr_str = _expr_str_val # Windows. def _main(): if len(sys.argv) > 2: - print("usage: {} [Kconfig]".format(sys.argv[0]), file=sys.stderr) - sys.exit(1) + sys.exit("usage: {} [Kconfig]".format(sys.argv[0])) menuconfig(Kconfig("Kconfig" if len(sys.argv) < 2 else sys.argv[1])) diff --git a/testsuite.py b/testsuite.py index 9faa92c..f157797 100644 --- a/testsuite.py +++ b/testsuite.py @@ -1921,8 +1921,7 @@ def run_compatibility_tests(): if all_passed: print("All selftests and compatibility tests passed") else: - print("Some tests failed") - sys.exit(1) + sys.exit("Some tests failed") def all_arch_srcarch_pairs(): for srcarch in os.listdir("arch"): -- cgit v1.2.3