Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3072)

Unified Diff: build/android/pylib/android_commands.py

Issue 11232037: Retry tests on other bots if the device is unresponsive/offline (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: small improvement Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | build/android/pylib/base_test_sharder.py » ('j') | build/android/pylib/base_test_sharder.py » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/android/pylib/android_commands.py
diff --git a/build/android/pylib/android_commands.py b/build/android/pylib/android_commands.py
index 8a1562caad5e298bff78291404890ead877ecd40..10255cb5de53975ffde9d6e5a00a9e93512bedea 100644
--- a/build/android/pylib/android_commands.py
+++ b/build/android/pylib/android_commands.py
@@ -107,6 +107,9 @@ def GetAttachedDevices():
devices.insert(0, preferred_device)
return devices
+def IsDeviceAttached(device):
+ return device in GetAttachedDevices()
+
def _GetFilesFromRecursiveLsOutput(path, ls_output, re_file, utc_offset=None):
"""Gets a list of files from `ls` command output.
@@ -196,6 +199,7 @@ class AndroidCommands(object):
self._adb = adb_interface.AdbInterface()
if device:
self._adb.SetTargetSerial(device)
+ self._device = device
self._logcat = None
self.logcat_process = None
self._pushed_files = []
@@ -1040,14 +1044,20 @@ class AndroidCommands(object):
True if the file exists, False otherwise.
"""
assert '"' not in file_name, 'file_name cannot contain double quotes'
- status = self._adb.SendShellCommand(
- '\'test -e "%s"; echo $?\'' % (file_name))
- if 'test: not found' not in status:
+ try:
+ status = self._adb.SendShellCommand(
+ '\'test -e "%s"; echo $?\'' % (file_name))
+ if 'test: not found' not in status:
+ return int(status) == 0
+
+ status = self._adb.SendShellCommand(
+ '\'ls "%s" >/dev/null 2>&1; echo $?\'' % (file_name))
return int(status) == 0
+ except ValueError:
+ if IsDeviceAttached(self._device):
+ raise errors.DeviceUnresponsiveError('Device may be offline.')
- status = self._adb.SendShellCommand(
- '\'ls "%s" >/dev/null 2>&1; echo $?\'' % (file_name))
- return int(status) == 0
+ return False
class NewLineNormalizer(object):
« no previous file with comments | « no previous file | build/android/pylib/base_test_sharder.py » ('j') | build/android/pylib/base_test_sharder.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698