servo_logging: Get the handled exception types from the caller.
The logging change introduced a new import, which breaks the
dut-console script:
~/chromiumos/src/platform/dev/contrib$ ./dut-console -c cpu
Traceback (most recent call last):
File "chromiumos/src/platform/dev/contrib/../../../../chroot/usr/lib64/python2.7/site-packages/servo/dut_control.py", line 21, in <module>
import servo_parsing
File "chromiumos/chroot/usr/lib64/python2.7/site-packages/servo/servo_parsing.py", line 12, in <module>
import servo_logging
File "chromiumos/chroot/usr/lib64/python2.7/site-packages/servo/servo_logging.py", line 37, in <module>
from .drv import hw_driver
ValueError: Attempted relative import in non-package
Cannot find pty cpu_uart_pty.
By moving the choice of exception class into the caller, this extra
import can be avoided.
BUG=None
TEST=Run servod, check for logging of commands.
TEST=Run dut-console, from contrib.
Change-Id: I9b5eb4c8f6bebf3ec6dcc30bdd5a532eb100ec1a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/hdctools/+/2095383
Tested-by: Dana Goyette <dgoyette@chromium.org>
Tested-by: Stephen Boyd <swboyd@chromium.org>
Reviewed-by: Stephen Boyd <swboyd@chromium.org>
Reviewed-by: Denis Brockus <dbrockus@chromium.org>
Reviewed-by: Ruben Rodriguez Buchillon <coconutruben@chromium.org>
Commit-Queue: Dana Goyette <dgoyette@chromium.org>
diff --git a/servo/servo_server.py b/servo/servo_server.py
index edb505a..888113f 100755
--- a/servo/servo_server.py
+++ b/servo/servo_server.py
@@ -756,7 +756,8 @@
# TODO(aaboagye): Refactor it.
return self.get_serial_number(name.split('serialname')[0].strip('_'))
- with servo_logging.WrapGetCall(name) as wrapper:
+ with servo_logging.WrapGetCall(
+ name, known_exceptions=(AttributeError, HwDriverError)) as wrapper:
(params, drv, device) = self._get_param_drv(name)
if device in self._devices:
self._devices[device].wait(self.INTERFACE_AVAILABILITY_TIMEOUT)
@@ -802,7 +803,8 @@
HwDriverError: Error occurred while using driver
ServodError: if interfaces are not available within timeout period
"""
- with servo_logging.WrapSetCall(name, wr_val_str):
+ with servo_logging.WrapSetCall(
+ name, wr_val_str, known_exceptions=(AttributeError, HwDriverError)):
(params, drv, device) = self._get_param_drv(name, False)
if device in self._devices:
self._devices[device].wait(self.INTERFACE_AVAILABILITY_TIMEOUT)