1
0
mirror of https://github.com/ARM-software/devlib.git synced 2024-10-06 02:40:50 +01:00

connetion: fixing None timeout issue

Connection objects set timeout to a default value in case a timeout is
not specified. However, Target defaults timeout to None and passes that
to connection, overridng the default.

This commit ensures that default timeout remains set if calling code
specified timemout as None.

Fix for issue

https://github.com/ARM-software/devlib/issues/34
This commit is contained in:
Sergei Trofimov 2016-05-17 14:00:01 +01:00
parent 1dc1e1364c
commit 89256fd408
2 changed files with 6 additions and 3 deletions

View File

@ -152,6 +152,7 @@ class AdbConnection(object):
# maintains the count of parallel active connections to a device, so that
# adb disconnect is not invoked untill all connections are closed
active_connections = defaultdict(int)
default_timeout = 10
@property
def name(self):
@ -168,8 +169,8 @@ class AdbConnection(object):
else:
raise DevlibError("Unknown line ending")
def __init__(self, device=None, timeout=10):
self.timeout = timeout
def __init__(self, device=None, timeout=None):
self.timeout = timeout if timeout is not None else self.default_timeout
if device is None:
device = adb_get_device(timeout=timeout)
self.device = device

View File

@ -127,6 +127,7 @@ class SshConnection(object):
default_password_prompt = '[sudo] password'
max_cancel_attempts = 5
default_timeout=10
@property
def name(self):
@ -138,7 +139,7 @@ class SshConnection(object):
password=None,
keyfile=None,
port=None,
timeout=10,
timeout=None,
telnet=False,
password_prompt=None,
):
@ -150,6 +151,7 @@ class SshConnection(object):
self.lock = threading.Lock()
self.password_prompt = password_prompt if password_prompt is not None else self.default_password_prompt
logger.debug('Logging in {}@{}'.format(username, host))
timeout = timeout if timeout is not None else self.default_timeout
self.conn = ssh_get_shell(host, username, password, self.keyfile, port, timeout, telnet)
def push(self, source, dest, timeout=30):