summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoe Brennan <jmbrenna@google.com>2017-02-16 08:42:47 -0800
committerJoe Brennan <jmbrenna@google.com>2017-02-17 16:11:34 -0800
commit9a6c6ebb4fdb178c3881398f6a577d80026c5e56 (patch)
tree8952d8983e2f0005ba90c3be20cfa81b47317704
parent86be20ef7b3fabe467f5ac46a1d69c1eae42999d (diff)
downloadplatform_tools_test_connectivity-9a6c6ebb4fdb178c3881398f6a577d80026c5e56.tar.gz
platform_tools_test_connectivity-9a6c6ebb4fdb178c3881398f6a577d80026c5e56.tar.bz2
platform_tools_test_connectivity-9a6c6ebb4fdb178c3881398f6a577d80026c5e56.zip
Made sl4a_client.py compatible with python2.7
Replaced timeout with **kwargs since for python2.7, it is required for the *args and **kwargs arguments to be last in arguments in the function declaration. This is not a requirement for python3.4 which is why this worked before. From PEP 3102. Bug: 35408415 Change-Id: I46cdfa7cf7f7f4b7e40445536bba50f07a4eedcb Fixes: 35408415 Test: import sl4a_client in python 2.7 and 3.4
-rw-r--r--acts/framework/acts/controllers/sl4a_client.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/acts/framework/acts/controllers/sl4a_client.py b/acts/framework/acts/controllers/sl4a_client.py
index fbdb4907a5..bf08e52e15 100644
--- a/acts/framework/acts/controllers/sl4a_client.py
+++ b/acts/framework/acts/controllers/sl4a_client.py
@@ -301,7 +301,7 @@ class Sl4aClient(object):
self.client.flush()
return self.client.readline()
- def _rpc(self, method, *args, timeout=None):
+ def _rpc(self, method, *args, **kwargs):
"""Sends an rpc to sl4a.
Sends an rpc call to sl4a using this clients connection.
@@ -320,8 +320,10 @@ class Sl4aClient(object):
"""
with self._lock:
apiid = next(self._counter)
- if timeout:
+ if kwargs.get("timeout"):
self.conn.settimeout(timeout)
+ else:
+ self.conn.settimeout(self._SOCKET_TIMEOUT)
data = {'id': apiid, 'method': method, 'params': args}
request = json.dumps(data)
self.client.write(request.encode("utf8") + b'\n')
@@ -330,7 +332,7 @@ class Sl4aClient(object):
if not response:
raise Sl4aProtocolError(Sl4aProtocolError.NO_RESPONSE_FROM_SERVER)
result = json.loads(str(response, encoding="utf8"))
- if timeout:
+ if kwargs.get("timeout"):
self.conn.settimeout(self._SOCKET_TIMEOUT)
if result['error']:
raise Sl4aApiError("RPC call %s failed with error %s" %