diff --git a/arch/x86/gen_gdt.py b/arch/x86/gen_gdt.py index da95e4204af..70fe90adb41 100755 --- a/arch/x86/gen_gdt.py +++ b/arch/x86/gen_gdt.py @@ -36,8 +36,7 @@ from elftools.elf.elffile import ELFFile from elftools.elf.sections import SymbolTableSection if LooseVersion(elftools.__version__) < LooseVersion('0.24'): - sys.stderr.write("pyelftools is out of date, need version 0.24 or later\n") - sys.exit(1) + sys.exit("pyelftools is out of date, need version 0.24 or later") def debug(text): @@ -47,8 +46,7 @@ def debug(text): def error(text): - sys.stderr.write(os.path.basename(sys.argv[0]) + ": " + text + "\n") - sys.exit(1) + sys.exit(os.path.basename(sys.argv[0]) + ": " + text) gdt_pd_fmt = " max_threads: - sys.stderr.write("Too many thread objects (%d)\n" % thread_counter) - sys.stderr.write("Increase CONFIG_MAX_THREAD_BYTES to %d\n" % - -(-thread_counter // 8)) - sys.exit(1) + sys.exit("Too many thread objects ({})\n" + "Increase CONFIG_MAX_THREAD_BYTES to {}" + .format(thread_counter, -(-thread_counter // 8))) with open(args.gperf_output, "w") as fp: write_gperf_table(fp, eh, objs, diff --git a/scripts/gen_priv_stacks.py b/scripts/gen_priv_stacks.py index a22616ebb2b..9db974f709d 100755 --- a/scripts/gen_priv_stacks.py +++ b/scripts/gen_priv_stacks.py @@ -128,10 +128,9 @@ def main(): thread_counter = eh.get_thread_counter() if thread_counter > max_threads: - sys.stderr.write("Too many thread objects (%d)\n" % thread_counter) - sys.stderr.write("Increase CONFIG_MAX_THREAD_BYTES to %d\n", - -(-thread_counter // 8)) - sys.exit(1) + sys.exit("Too many thread objects ({})\n" + "Increase CONFIG_MAX_THREAD_BYTES to {}" + .format(thread_counter, -(-thread_counter // 8))) with open(args.output, "w") as fp: write_gperf_table(fp, eh, objs) diff --git a/scripts/gen_relocate_app.py b/scripts/gen_relocate_app.py index a206d23094a..69239a35894 100644 --- a/scripts/gen_relocate_app.py +++ b/scripts/gen_relocate_app.py @@ -133,8 +133,7 @@ def find_sections(filename, full_list_of_sections): with open(filename, 'rb') as obj_file_desc: full_lib = ELFFile(obj_file_desc) if not full_lib: - print("Error parsing file: ", filename) - sys.exit(1) + sys.exit("Error parsing file: " + filename) sections = [x for x in full_lib.iter_sections()] @@ -380,8 +379,7 @@ def create_dict_wrt_mem(): #need to support wild card * rel_dict = dict() if args.input_rel_dict == '': - print("Disable CONFIG_CODE_DATA_RELOCATION if no file needs relocation") - sys.exit(1) + sys.exit("Disable CONFIG_CODE_DATA_RELOCATION if no file needs relocation") for line in args.input_rel_dict.split(';'): mem_region, file_name = line.split(':') diff --git a/scripts/process_gperf.py b/scripts/process_gperf.py index 4dc615fd861..921f0ac9bf2 100755 --- a/scripts/process_gperf.py +++ b/scripts/process_gperf.py @@ -32,8 +32,7 @@ def debug(text): def error(text): - sys.stderr.write(os.path.basename(sys.argv[0]) + " ERROR: " + text + "\n") - sys.exit(1) + sys.exit(os.path.basename(sys.argv[0]) + " ERROR: " + text) def warn(text): diff --git a/scripts/sanity_chk/expr_parser.py b/scripts/sanity_chk/expr_parser.py index 3d3ad28ed53..b28af219a39 100644 --- a/scripts/sanity_chk/expr_parser.py +++ b/scripts/sanity_chk/expr_parser.py @@ -14,10 +14,9 @@ try: import ply.lex as lex import ply.yacc as yacc except ImportError: - print("PLY library for Python 3 not installed.") - print("Please install the ply package using your workstation's") - print("package manager or the 'pip' tool.") - sys.exit(1) + sys.exit("PLY library for Python 3 not installed.\n" + "Please install the ply package using your workstation's\n" + "package manager or the 'pip' tool.") reserved = { 'and' : 'AND', diff --git a/scripts/support/quartus-flash.py b/scripts/support/quartus-flash.py index f4aadf0ddd6..0931f3a23c5 100755 --- a/scripts/support/quartus-flash.py +++ b/scripts/support/quartus-flash.py @@ -94,9 +94,8 @@ def create_pof(input_sof, kernel_hex): try: subprocess.check_output(cmd) except subprocess.CalledProcessError as cpe: - print(cpe.output.decode("UTF-8")) - print("Failed to create POF file") - sys.exit(1) + sys.exit(cpe.output.decode("utf-8") + + "\nFailed to create POF file") return output_pof @@ -114,9 +113,8 @@ def flash_kernel(device_id, input_sof, kernel_hex): try: subprocess.check_output(cmd) except subprocess.CalledProcessError as cpe: - print(cpe.output.decode("UTF-8")) - print("Failed to flash image") - sys.exit(1) + sys.exit(cpe.output.decode("utf-8") + + "\nFailed to flash image") pof_file.close() def main(): diff --git a/scripts/zephyr_module.py b/scripts/zephyr_module.py index fb945bb3215..970cb54d1f9 100755 --- a/scripts/zephyr_module.py +++ b/scripts/zephyr_module.py @@ -68,24 +68,21 @@ def process_module(module, cmake_out=None, kconfig_out=None): pykwalify.core.Core(source_data=meta, schema_data=schema)\ .validate() except pykwalify.errors.SchemaError as e: - print('ERROR: Malformed "build" section in file: {}\n{}' - .format(module_yml, e), file=sys.stderr) - sys.exit(1) + sys.exit('ERROR: Malformed "build" section in file: {}\n{}' + .format(module_yml, e)) section = meta.get('build', dict()) cmake_setting = section.get('cmake', None) if not validate_setting(cmake_setting, module, 'CMakeLists.txt'): - print('ERROR: "cmake" key in {} has folder value "{}" which ' - 'does not contain a CMakeLists.txt file.' - .format(module_yml, cmake_setting), file=sys.stderr) - sys.exit(1) + sys.exit('ERROR: "cmake" key in {} has folder value "{}" which ' + 'does not contain a CMakeLists.txt file.' + .format(module_yml, cmake_setting)) kconfig_setting = section.get('kconfig', None) if not validate_setting(kconfig_setting, module): - print('ERROR: "kconfig" key in {} has value "{}" which does not ' - 'point to a valid Kconfig file.' - .format(module_yml, kconfig_setting), file=sys.stderr) - sys.exit(1) + sys.exit('ERROR: "kconfig" key in {} has value "{}" which does ' + 'not point to a valid Kconfig file.' + .format(module.yml, kconfig_setting)) cmake_path = os.path.join(module, cmake_setting or 'zephyr') cmake_file = os.path.join(cmake_path, 'CMakeLists.txt')