Merge pull request #196 from bjackman/is-network-connected

target: Ensure returning False when is_network_connected fails
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 @@
         # 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 @@
                     # error.
                     raise
 
+        self.logger.debug('Failed to ping {} after {} attempts'.format(
+            GOOGLE_DNS_SERVER_ADDRESS, attempts))
+        return False
+
 class LinuxTarget(Target):
 
     path = posixpath