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

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

Issue 839143002: Roll Chrome into Mojo. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Rebase Created 5 years, 11 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/device/adb_wrapper.py ('k') | build/android/pylib/device/device_utils.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/android/pylib/device/device_errors.py
diff --git a/build/android/pylib/device/device_errors.py b/build/android/pylib/device/device_errors.py
index 170637d5a3674c61c45347bdfcdb35ea4c61795f..c47c9668ed1a37b19556d6b5bf3e4262adac39f8 100644
--- a/build/android/pylib/device/device_errors.py
+++ b/build/android/pylib/device/device_errors.py
@@ -27,25 +27,41 @@ class CommandFailedError(BaseError):
class AdbCommandFailedError(CommandFailedError):
"""Exception for adb command failures."""
- def __init__(self, cmd, output, status=None, device_serial=None):
- self.cmd = cmd
+ def __init__(self, args, output, status=None, device_serial=None,
+ message=None):
+ self.args = args
self.output = output
self.status = status
- message = []
- if self.cmd[0] == 'shell':
- assert len(self.cmd) == 2
- message.append('adb shell command %r failed with' % self.cmd[1])
- else:
- command = ' '.join(cmd_helper.SingleQuote(arg) for arg in self.cmd)
- message.append('adb command %r failed with' % command)
- if status:
- message.append(' exit status %d and' % self.status)
+ if not message:
+ adb_cmd = ' '.join(cmd_helper.SingleQuote(arg) for arg in self.args)
+ message = ['adb %s: failed ' % adb_cmd]
+ if status:
+ message.append('with exit status %s ' % self.status)
+ if output:
+ message.append('and output:\n')
+ message.extend('- %s\n' % line for line in output.splitlines())
+ else:
+ message.append('and no output.')
+ message = ''.join(message)
+ super(AdbCommandFailedError, self).__init__(message, device_serial)
+
+
+class AdbShellCommandFailedError(AdbCommandFailedError):
+ """Exception for shell command failures run via adb."""
+
+ def __init__(self, command, output, status, device_serial=None):
+ self.command = command
+ message = ['shell command run via adb failed on the device:\n',
+ ' command: %s\n' % command]
+ message.append(' exit status: %s\n' % status)
if output:
- message.append(' output:\n')
- message.extend('> %s\n' % line for line in output.splitlines())
+ message.append(' output:\n')
+ message.extend(' - %s\n' % line for line in output.splitlines())
else:
- message.append(' no output')
- super(AdbCommandFailedError, self).__init__(''.join(message), device_serial)
+ message.append(" output: ''\n")
+ message = ''.join(message)
+ super(AdbShellCommandFailedError, self).__init__(
+ ['shell', command], output, status, device_serial, message)
class CommandTimeoutError(BaseError):
« no previous file with comments | « build/android/pylib/device/adb_wrapper.py ('k') | build/android/pylib/device/device_utils.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698