From 417ab3df3e292393bd6c75046091815ade575f79 Mon Sep 17 00:00:00 2001 From: Brendan Jackman Date: Tue, 24 Oct 2017 16:03:10 +0100 Subject: [PATCH] target: Ensure returning False when is_network_connected fails --- devlib/target.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/devlib/target.py b/devlib/target.py index 1d2754f..aea3331 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