From 0ec20a463067a9085c312ded313b065cbecb70aa Mon Sep 17 00:00:00 2001 From: deveco_test Date: Mon, 15 Aug 2022 10:56:07 +0800 Subject: [PATCH] fix code reivewbot bug Signed-off-by: deveco_test --- plugins/ohos/src/ohos/drivers/drivers.py | 8 +++----- plugins/ohos/src/ohos/environment/device.py | 8 ++------ src/xdevice/_core/executor/concurrent.py | 11 +++++------ 3 files changed, 10 insertions(+), 17 deletions(-) diff --git a/plugins/ohos/src/ohos/drivers/drivers.py b/plugins/ohos/src/ohos/drivers/drivers.py index fffa1a9..8e455f7 100644 --- a/plugins/ohos/src/ohos/drivers/drivers.py +++ b/plugins/ohos/src/ohos/drivers/drivers.py @@ -1768,9 +1768,8 @@ class DexTestDriver(IDriver): if not getattr("exception", "error_no", ""): setattr(exception, "error_no", "03203") return_message = str(exception.args) - finally: - shutil.rmtree(long_command_path) - return return_message + shutil.rmtree(long_command_path) + return return_message @staticmethod def _make_long_command_file(command, longcommand_path, filename): @@ -1785,8 +1784,7 @@ class DexTestDriver(IDriver): except(IOError, ValueError) as err_msg: LOG.exception("Error for make long command file: ", err_msg, exc_info=False, error_no="03200") - finally: - return sh_file_name, file_path + return sh_file_name, file_path def __result__(self): return self.result if os.path.exists(self.result) else "" diff --git a/plugins/ohos/src/ohos/environment/device.py b/plugins/ohos/src/ohos/environment/device.py index 1260f1e..e0e3eb5 100644 --- a/plugins/ohos/src/ohos/environment/device.py +++ b/plugins/ohos/src/ohos/environment/device.py @@ -602,8 +602,7 @@ class Device(IDevice): self._proxy = OpenHarmony(port=self._h_port, addr=self.host, device=self) except Exception as error: self.log.error(' proxy init error: {}.'.format(str(error))) - finally: - return self._proxy + return self._proxy def start_harmony_rpc(self, port=8080, re_install_rpc=False): from devicetest.core.error_message import ErrorMessage @@ -706,8 +705,6 @@ class Device(IDevice): return ret except Exception as err: self.log.error('DeviceTest-20013 uninstall: %s' % str(err)) - finally: - return False def reconnect(self, waittime=60): ''' @@ -792,8 +789,7 @@ class Device(IDevice): self.pull_file("/data/screen.png", path) except Exception as error: self.log.error("devicetest take_picture: {}".format(str(error))) - finally: - return path + return path def set_device_report_path(self, path): self._device_log_path = path \ No newline at end of file diff --git a/src/xdevice/_core/executor/concurrent.py b/src/xdevice/_core/executor/concurrent.py index 77067da..b5184cf 100644 --- a/src/xdevice/_core/executor/concurrent.py +++ b/src/xdevice/_core/executor/concurrent.py @@ -273,12 +273,11 @@ class DriversThread(threading.Thread): failed_list = params[ReportConst.unsuccessful_params].get(module_name, []) except Exception: failed_list = params[ReportConst.unsuccessful_params].get(module_name, []) - finally: - if not failed_list: - failed_list = params[ReportConst.unsuccessful_params].get(str(module_name).split(".")[0], []) - unpassed_test_params.extend(failed_list) - LOG.debug("Get unpassed test params %s", unpassed_test_params) - return unpassed_test_params + if not failed_list: + failed_list = params[ReportConst.unsuccessful_params].get(str(module_name).split(".")[0], []) + unpassed_test_params.extend(failed_list) + LOG.debug("Get unpassed test params %s", unpassed_test_params) + return unpassed_test_params @classmethod def _append_unpassed_test_param(cls, history_report_file, -- GitLab