Handle string conversion of remote methods and better logging.
Since we turn off allow_dotted_names option on XML RPC server. So any string
conversion, like str(FAFTClient.method), i.e. FAFTClient.method.__str__, failed
via XML RPC call. We printed a fixed string "<remote_method>" before.
We now create the _dispatch() method to handle this case.
BUG=chromium-os:22598
TEST=run_remote_tests.sh --remote=$REMOTE_IP -a "xml_config=$OVERLAY_XML \
servo_vid=0x18d1 servo_pid=0x5001" TryFwB/control.normal
Change-Id: I26a646636752aa758416b383ffff78d967e20012
Reviewed-on: https://gerrit.chromium.org/gerrit/12664
Commit-Ready: Tom Wai-Hong Tam <waihong@chromium.org>
Reviewed-by: Tom Wai-Hong Tam <waihong@chromium.org>
Tested-by: Tom Wai-Hong Tam <waihong@chromium.org>
diff --git a/client/cros/faft_client.py b/client/cros/faft_client.py
index c329388..220e837 100644
--- a/client/cros/faft_client.py
+++ b/client/cros/faft_client.py
@@ -71,6 +71,27 @@
self._tpm_handler.init(self._chromeos_interface)
+ def _dispatch(self, method, params):
+ """This _dispatch method handles string conversion especially.
+
+ Since we turn off allow_dotted_names option. So any string conversion,
+ like str(FAFTClient.method), i.e. FAFTClient.method.__str__, failed
+ via XML RPC call.
+ """
+ is_str = method.endswith('.__str__')
+ if is_str:
+ method = method.rsplit('.', 1)[0]
+ try:
+ func = getattr(self, method)
+ except AttributeError:
+ raise Exception('method "%s" is not supported' % method)
+ else:
+ if is_str:
+ return str(func)
+ else:
+ return func(*params)
+
+
def is_available(self):
"""Function for polling the RPC server availability.