From 07c71ac1b9fc5b36a09a7cd3fe33939e73b684c4 Mon Sep 17 00:00:00 2001 From: Kelvin Zhang Date: Thu, 17 Feb 2022 21:46:21 -0800 Subject: [PATCH] Remove catch + sys.exit idiom This is bad, python already prints exceptino message and exit with non-zero code when an exception is raised, no need to catch the exception just to print it. In addition, printing an exception does not print stacktrace, so catch + sys.exit provide less information than python's default behavior. Test: th Change-Id: If6cf2e34d4ebc9f7d172063b4396bf4377dad447 --- tools/releasetools/check_ota_package_signature.py | 3 --- tools/releasetools/check_partition_sizes.py | 3 --- tools/releasetools/check_target_files_vintf.py | 3 --- tools/releasetools/img_from_target_files.py | 3 --- tools/releasetools/sign_apex.py | 3 --- 5 files changed, 15 deletions(-) diff --git a/tools/releasetools/check_ota_package_signature.py b/tools/releasetools/check_ota_package_signature.py index 58510a52d2..b395c196d0 100755 --- a/tools/releasetools/check_ota_package_signature.py +++ b/tools/releasetools/check_ota_package_signature.py @@ -181,8 +181,5 @@ def main(): if __name__ == '__main__': try: main() - except AssertionError as err: - print('\n ERROR: %s\n' % (err,)) - sys.exit(1) finally: common.Cleanup() diff --git a/tools/releasetools/check_partition_sizes.py b/tools/releasetools/check_partition_sizes.py index eaed07e877..738d77d63e 100644 --- a/tools/releasetools/check_partition_sizes.py +++ b/tools/releasetools/check_partition_sizes.py @@ -300,8 +300,5 @@ if __name__ == "__main__": try: common.CloseInheritedPipes() main(sys.argv[1:]) - except common.ExternalError: - logger.exception("\n ERROR:\n") - sys.exit(1) finally: common.Cleanup() diff --git a/tools/releasetools/check_target_files_vintf.py b/tools/releasetools/check_target_files_vintf.py index 6fc79d2b3a..4bcbd8eeab 100755 --- a/tools/releasetools/check_target_files_vintf.py +++ b/tools/releasetools/check_target_files_vintf.py @@ -286,8 +286,5 @@ if __name__ == '__main__': try: common.CloseInheritedPipes() main(sys.argv[1:]) - except common.ExternalError: - logger.exception('\n ERROR:\n') - sys.exit(1) finally: common.Cleanup() diff --git a/tools/releasetools/img_from_target_files.py b/tools/releasetools/img_from_target_files.py index 0b2b1870c1..76da89c865 100755 --- a/tools/releasetools/img_from_target_files.py +++ b/tools/releasetools/img_from_target_files.py @@ -251,8 +251,5 @@ if __name__ == '__main__': try: common.CloseInheritedPipes() main(sys.argv[1:]) - except common.ExternalError as e: - logger.exception('\n ERROR:\n') - sys.exit(1) finally: common.Cleanup() diff --git a/tools/releasetools/sign_apex.py b/tools/releasetools/sign_apex.py index 66f5e0513a..692646705e 100755 --- a/tools/releasetools/sign_apex.py +++ b/tools/releasetools/sign_apex.py @@ -149,8 +149,5 @@ def main(argv): if __name__ == '__main__': try: main(sys.argv[1:]) - except common.ExternalError: - logger.exception("\n ERROR:\n") - sys.exit(1) finally: common.Cleanup()