aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsetrofim <setrofim@gmail.com>2017-10-24 16:29:17 +0100
committerGitHub <noreply@github.com>2017-10-24 16:29:17 +0100
commitaf0ed2ab4806fa15edec3f16c83c651da82a5757 (patch)
tree126c59ca7a18b652718daae5bef2b5e5a7dc2202
parentdcffccbb690fbc636d66383a4010c84ebf1bd141 (diff)
parent417ab3df3e292393bd6c75046091815ade575f79 (diff)
downloaddevlib-af0ed2ab4806fa15edec3f16c83c651da82a5757.tar.gz
Merge pull request #196 from bjackman/is-network-connected
target: Ensure returning False when is_network_connected fails
-rw-r--r--devlib/target.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/devlib/target.py b/devlib/target.py
index 29cd411..350ce55 100644
--- a/devlib/target.py
+++ b/devlib/target.py
@@ -715,7 +715,8 @@ class Target(object):
# We'll use our own retrying mechanism (rather than just using ping's -c
# to send multiple packets) so that we don't slow things down in the
# 'good' case where the first packet gets echoed really quickly.
- for _ in range(5):
+ attempts = 5
+ for _ in range(attempts):
try:
self.execute(command)
return True
@@ -737,6 +738,10 @@ class Target(object):
# error.
raise
+ self.logger.debug('Failed to ping {} after {} attempts'.format(
+ GOOGLE_DNS_SERVER_ADDRESS, attempts))
+ return False
+
class LinuxTarget(Target):
path = posixpath