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

Side by Side Diff: build/android/pylib/device/device_errors.py

Issue 2101243005: Add a snapshot of flutter/engine/src/build to our sdk (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: add README.dart Created 4 years, 5 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 unified diff | Download patch
OLDNEW
(Empty)
1 # Copyright 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4
5 """
6 Exception classes raised by AdbWrapper and DeviceUtils.
7 """
8
9 from pylib import cmd_helper
10 from pylib.utils import base_error
11
12
13 class CommandFailedError(base_error.BaseError):
14 """Exception for command failures."""
15
16 def __init__(self, message, device_serial=None):
17 if device_serial is not None:
18 message = '(device: %s) %s' % (device_serial, message)
19 self.device_serial = device_serial
20 super(CommandFailedError, self).__init__(message)
21
22
23 class AdbCommandFailedError(CommandFailedError):
24 """Exception for adb command failures."""
25
26 def __init__(self, args, output, status=None, device_serial=None,
27 message=None):
28 self.args = args
29 self.output = output
30 self.status = status
31 if not message:
32 adb_cmd = ' '.join(cmd_helper.SingleQuote(arg) for arg in self.args)
33 message = ['adb %s: failed ' % adb_cmd]
34 if status:
35 message.append('with exit status %s ' % self.status)
36 if output:
37 message.append('and output:\n')
38 message.extend('- %s\n' % line for line in output.splitlines())
39 else:
40 message.append('and no output.')
41 message = ''.join(message)
42 super(AdbCommandFailedError, self).__init__(message, device_serial)
43
44
45 class DeviceVersionError(CommandFailedError):
46 """Exception for device version failures."""
47
48 def __init__(self, message, device_serial=None):
49 super(DeviceVersionError, self).__init__(message, device_serial)
50
51
52 class AdbShellCommandFailedError(AdbCommandFailedError):
53 """Exception for shell command failures run via adb."""
54
55 def __init__(self, command, output, status, device_serial=None):
56 self.command = command
57 message = ['shell command run via adb failed on the device:\n',
58 ' command: %s\n' % command]
59 message.append(' exit status: %s\n' % status)
60 if output:
61 message.append(' output:\n')
62 if isinstance(output, basestring):
63 output_lines = output.splitlines()
64 else:
65 output_lines = output
66 message.extend(' - %s\n' % line for line in output_lines)
67 else:
68 message.append(" output: ''\n")
69 message = ''.join(message)
70 super(AdbShellCommandFailedError, self).__init__(
71 ['shell', command], output, status, device_serial, message)
72
73
74 class CommandTimeoutError(base_error.BaseError):
75 """Exception for command timeouts."""
76 pass
77
78
79 class DeviceUnreachableError(base_error.BaseError):
80 """Exception for device unreachable failures."""
81 pass
82
83
84 class NoDevicesError(base_error.BaseError):
85 """Exception for having no devices attached."""
86
87 def __init__(self):
88 super(NoDevicesError, self).__init__(
89 'No devices attached.', is_infra_error=True)
OLDNEW
« no previous file with comments | « build/android/pylib/device/device_blacklist.py ('k') | build/android/pylib/device/device_list.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698