OLD | NEW |
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 """Provides an interface to communicate with the device via the adb command. | 5 """Provides an interface to communicate with the device via the adb command. |
6 | 6 |
7 Assumes adb binary is currently on system path. | 7 Assumes adb binary is currently on system path. |
8 """ | 8 """ |
9 | 9 |
10 import collections | 10 import collections |
(...skipping 623 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
634 shell command. | 634 shell command. |
635 | 635 |
636 Returns: | 636 Returns: |
637 list containing the lines of output received from running the command | 637 list containing the lines of output received from running the command |
638 """ | 638 """ |
639 self._CheckCommandIsValid(command) | 639 self._CheckCommandIsValid(command) |
640 self._LogShell(command) | 640 self._LogShell(command) |
641 if "'" in command: logging.warning(command + " contains ' quotes") | 641 if "'" in command: logging.warning(command + " contains ' quotes") |
642 result = self._adb.SendShellCommand( | 642 result = self._adb.SendShellCommand( |
643 "'%s'" % command, timeout_time).splitlines() | 643 "'%s'" % command, timeout_time).splitlines() |
| 644 # TODO(b.kelemen): we should really be able to drop the stderr of the |
| 645 # command or raise an exception based on what the caller wants. |
| 646 result = [ l for l in result if not l.startswith('WARNING') ] |
644 if ['error: device not found'] == result: | 647 if ['error: device not found'] == result: |
645 raise errors.DeviceUnresponsiveError('device not found') | 648 raise errors.DeviceUnresponsiveError('device not found') |
646 if log_result: | 649 if log_result: |
647 self._LogShell('\n'.join(result)) | 650 self._LogShell('\n'.join(result)) |
648 return result | 651 return result |
649 | 652 |
650 def GetShellCommandStatusAndOutput(self, command, timeout_time=20, | 653 def GetShellCommandStatusAndOutput(self, command, timeout_time=20, |
651 log_result=False): | 654 log_result=False): |
652 """See RunShellCommand() above. | 655 """See RunShellCommand() above. |
653 | 656 |
(...skipping 1130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1784 """ | 1787 """ |
1785 def __init__(self, output): | 1788 def __init__(self, output): |
1786 self._output = output | 1789 self._output = output |
1787 | 1790 |
1788 def write(self, data): | 1791 def write(self, data): |
1789 data = data.replace('\r\r\n', '\n') | 1792 data = data.replace('\r\r\n', '\n') |
1790 self._output.write(data) | 1793 self._output.write(data) |
1791 | 1794 |
1792 def flush(self): | 1795 def flush(self): |
1793 self._output.flush() | 1796 self._output.flush() |
OLD | NEW |