From 66cd32ec1b1d725063e26ff3f03ea4811b253514 Mon Sep 17 00:00:00 2001 From: rickwu4444 Date: Tue, 24 Dec 2024 11:10:56 +0800 Subject: [PATCH] change error message to handle by raise SystemError --- .../checkbox-provider-ce-oem/bin/wifi_test.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/contrib/checkbox-ce-oem/checkbox-provider-ce-oem/bin/wifi_test.py b/contrib/checkbox-ce-oem/checkbox-provider-ce-oem/bin/wifi_test.py index 03072ea077..d20962fb31 100755 --- a/contrib/checkbox-ce-oem/checkbox-provider-ce-oem/bin/wifi_test.py +++ b/contrib/checkbox-ce-oem/checkbox-provider-ce-oem/bin/wifi_test.py @@ -200,8 +200,7 @@ def connect_dut_from_host_via_wifi(host_net_info: dict, connect_info: dict): run_command(ping_cmd(ip)) logging.info("Ping to target host %s successful.", ip) except Exception as e: - logging.error("Unable to ping the HOST! Error: %s", str(e)) - raise SystemError() + raise SystemError("Unable to ping the HOST! Error: %s", str(e)) try: for i in range(1, 11): logging.info( @@ -227,13 +226,13 @@ def connect_dut_from_host_via_wifi(host_net_info: dict, connect_info: dict): run_command(sshpass_cmd_gen(ip, user, pwd, del_host_conn)) logging.info("Deleted host connection successfully.") except Exception as e: - logging.error("Failed to delete host connection: %s", str(e)) - raise SystemError() + raise SystemError( + "Failed to delete host connection: %s", str(e) + ) else: - logging.error( + raise SystemError( "Unable to connect to DUT AP SSID %s after 10 attempts.", ssid ) - raise SystemError() def ping_test(target_ip, host_net_info: dict): @@ -346,8 +345,8 @@ def main(): with connect_dut_from_host_via_wifi(host_net_info, connect_info): ret = ping_test(manager.get_ip_addr(), host_net_info) sys.exit(ret) - except SystemError: - logging.error("Failed to establish connection or perform cleanup.") + except SystemError as e: + logging.error(e) sys.exit(1)