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

Unified Diff: build/android/pylib/device/adb_wrapper.py

Issue 669573003: Reland of 'New run shell implementation for DeviceUtils' (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: better error handling when return code is not found Created 6 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 | « build/android/pylib/cmd_helper_test.py ('k') | build/android/pylib/device/adb_wrapper_test.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/android/pylib/device/adb_wrapper.py
diff --git a/build/android/pylib/device/adb_wrapper.py b/build/android/pylib/device/adb_wrapper.py
index f4a5931121acc5db030fea1b8e2bbf9bbf8b3271..f6ac660c276176c5bd75ded89fac57f63cf70243 100644
--- a/build/android/pylib/device/adb_wrapper.py
+++ b/build/android/pylib/device/adb_wrapper.py
@@ -171,18 +171,27 @@ class AdbWrapper(object):
if expect_rc is None:
actual_command = command
else:
- actual_command = '%s; echo $?;' % command
+ actual_command = '%s; echo %%$?;' % command.rstrip()
output = self._DeviceAdbCmd(
['shell', actual_command], timeout, retries, check_error=False)
if expect_rc is not None:
- output_end = output.rstrip().rfind('\n') + 1
- rc = output[output_end:].strip()
- output = output[:output_end]
- if int(rc) != expect_rc:
+ output_end = output.rfind('%')
perezju 2014/10/20 16:20:01 Trying to find our own marker, rather than a new l
+ if output_end < 0:
+ # causes the string for rc to become empty and also raise a ValueError
+ output_end = len(output)
+
+ try:
+ rc = int(output[output_end+1:])
+ except ValueError:
raise device_errors.AdbCommandFailedError(
- ['shell', command],
- 'shell command exited with code: %s' % rc,
+ ['shell'], 'command %r on device produced output %r where no'
+ ' valid return code was found' % (actual_command, output),
self._device_serial)
+
+ output = output[:output_end]
+ if rc != expect_rc:
+ raise device_errors.AdbShellCommandFailedError(
+ command, rc, output, self._device_serial)
return output
def Logcat(self, filter_spec=None, timeout=_DEFAULT_TIMEOUT,
« no previous file with comments | « build/android/pylib/cmd_helper_test.py ('k') | build/android/pylib/device/adb_wrapper_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698