From 1f1430a412bad731bd23a0a92abcf0024fb739b3 Mon Sep 17 00:00:00 2001 From: deveco_xdevice Date: Tue, 20 Sep 2022 11:40:47 +0800 Subject: [PATCH] fix codestyle bug Signed-off-by: deveco_xdevice --- plugins/ohos/src/ohos/environment/dmlib.py | 8 ++++---- plugins/ohos/src/ohos/managers/manager_device.py | 2 +- src/xdevice/_core/command/console.py | 2 +- src/xdevice/_core/environment/device_monitor.py | 8 ++++---- src/xdevice/_core/logger.py | 4 ++-- src/xdevice/_core/utils.py | 6 +++--- 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/plugins/ohos/src/ohos/environment/dmlib.py b/plugins/ohos/src/ohos/environment/dmlib.py index 941d929..d07faf7 100644 --- a/plugins/ohos/src/ohos/environment/dmlib.py +++ b/plugins/ohos/src/ohos/environment/dmlib.py @@ -382,7 +382,7 @@ class SyncService: Return true if the connection opened, false if hdc refuse the connection. This can happen device is invalid. """ - LOG.debug("Open sync, timeout=%s" % int(timeout/1000)) + LOG.debug("Open sync, timeout=%s" % int(timeout / 1000)) self.sock = HdcHelper.socket(host=self.host, port=self.port, timeout=timeout) HdcHelper.set_device(self.device, self.sock) @@ -813,7 +813,7 @@ class HdcHelper: with HdcHelper.socket(host=device.host, port=device.port, timeout=timeout) as sock: output_flag = kwargs.get("output_flag", True) - timeout_msg = " with timeout %ss" % str(timeout/1000) + timeout_msg = " with timeout %ss" % str(timeout / 1000) message = "%s execute command: hdc shell %s%s" % \ (convert_serial(device.device_sn), command, timeout_msg) @@ -845,7 +845,7 @@ class HdcHelper: return resp except socket.timeout as _: device.log.error("%s shell %s timeout[%sS]" % ( - convert_serial(device.device_sn), command, str(timeout/1000))) + convert_serial(device.device_sn), command, str(timeout / 1000))) raise ShellCommandUnresponsiveException() finally: if receiver: @@ -1005,7 +1005,7 @@ class HdcHelper: if timeout is not None: sock.setblocking(False) - sock.settimeout(timeout/1000) + sock.settimeout(timeout / 1000) return sock diff --git a/plugins/ohos/src/ohos/managers/manager_device.py b/plugins/ohos/src/ohos/managers/manager_device.py index 831b863..4b03201 100644 --- a/plugins/ohos/src/ohos/managers/manager_device.py +++ b/plugins/ohos/src/ohos/managers/manager_device.py @@ -196,7 +196,7 @@ class ManagerDevice(IDeviceManager): else: device_dict = dict(zip( self.global_device_filter, - list(range(1, len(self.global_device_filter)+1)))) + list(range(1, len(self.global_device_filter) + 1)))) for index in range(len(self.devices_list)): if self.devices_list[index].device_sn not in \ self.global_device_filter: diff --git a/src/xdevice/_core/command/console.py b/src/xdevice/_core/command/console.py index 9831ab2..499a824 100644 --- a/src/xdevice/_core/command/console.py +++ b/src/xdevice/_core/command/console.py @@ -456,7 +456,7 @@ class Console(object): split_list = list(history_command.split()) if "--repeat" in split_list: pos = split_list.index("--repeat") - split_list = split_list[:pos] + split_list[pos+2:] + split_list = split_list[:pos] + split_list[pos + 2:] history_command = " ".join(split_list) argument = self.argument_parser(history_command.split()) diff --git a/src/xdevice/_core/environment/device_monitor.py b/src/xdevice/_core/environment/device_monitor.py index d3f9241..ffac244 100644 --- a/src/xdevice/_core/environment/device_monitor.py +++ b/src/xdevice/_core/environment/device_monitor.py @@ -80,10 +80,10 @@ class DeviceStateMonitor(object): def wait_for_boot_complete(self, wait_time): counter = 1 - start_time = int(time.time()*1000) + start_time = int(time.time() * 1000) self.device.log.debug("wait for boot complete, and wait time: %s ms" % wait_time) - while int(time.time()*1000) - start_time < wait_time: + while int(time.time() * 1000) - start_time < wait_time: try: result = self.device.get_recover_result(retry=0) if self.device.check_recover_result(result): @@ -99,10 +99,10 @@ class DeviceStateMonitor(object): def wait_for_device_available(self, wait_time=None): if not wait_time: wait_time = self.default_available_timeout - start_time = int(time.time()*1000) + start_time = int(time.time() * 1000) if not self.wait_for_device_online(wait_time): return False - elapsed_time = int(time.time()*1000) - start_time + elapsed_time = int(time.time() * 1000) - start_time if not self.wait_for_boot_complete(wait_time - elapsed_time): return False return True diff --git a/src/xdevice/_core/logger.py b/src/xdevice/_core/logger.py index 35a2089..bc8b772 100644 --- a/src/xdevice/_core/logger.py +++ b/src/xdevice/_core/logger.py @@ -401,8 +401,8 @@ class EncryptFileHandler(RotatingFileHandler): stream = getattr(self, "stream", self._open()) stream.write(msg) self.flush() - except RecursionError as _: # pylint:disable=undefined-variable - raise + except RecursionError as error: # pylint:disable=undefined-variable + raise error def _encrypt_valid(self): from _core.report.encrypt import check_pub_key_exist diff --git a/src/xdevice/_core/utils.py b/src/xdevice/_core/utils.py index ba22986..f977bf3 100644 --- a/src/xdevice/_core/utils.py +++ b/src/xdevice/_core/utils.py @@ -491,7 +491,7 @@ def convert_ip(origin_ip): addr = origin_ip.strip().split(".") if len(addr) == 4: return "{}.{}.{}.{}".format( - addr[0], '*'*len(addr[1]), '*'*len(addr[2]), addr[-1]) + addr[0], '*' * len(addr[1]), '*' * len(addr[2]), addr[-1]) else: return origin_ip @@ -511,9 +511,9 @@ def convert_serial(serial): return "remote_{}_{}".format(convert_ip(serial.split("_")[1]), convert_port(serial.split("_")[-1])) else: - length = len(serial)//3 + length = len(serial) // 3 return "{}{}{}".format( - serial[0:length], "*"*(len(serial)-length*2), serial[-length:]) + serial[0:length], "*" * (len(serial) - length * 2), serial[-length:]) def get_shell_handler(request, parser_type):