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 # pylint: disable-all | 9 # pylint: disable-all |
10 | 10 |
(...skipping 683 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
694 return self.GetShellCommandStatusAndOutput(command, *args, **kw) | 694 return self.GetShellCommandStatusAndOutput(command, *args, **kw) |
695 | 695 |
696 # It is tempting to turn this function into a generator, however this is not | 696 # It is tempting to turn this function into a generator, however this is not |
697 # possible without using a private (local) adb_shell instance (to ensure no | 697 # possible without using a private (local) adb_shell instance (to ensure no |
698 # other command interleaves usage of it), which would defeat the main aim of | 698 # other command interleaves usage of it), which would defeat the main aim of |
699 # being able to reuse the adb shell instance across commands. | 699 # being able to reuse the adb shell instance across commands. |
700 def RunShellCommand(self, command, timeout_time=20, log_result=False): | 700 def RunShellCommand(self, command, timeout_time=20, log_result=False): |
701 """Send a command to the adb shell and return the result. | 701 """Send a command to the adb shell and return the result. |
702 | 702 |
703 Args: | 703 Args: |
704 command: String containing the shell command to send. Must not include | 704 command: String containing the shell command to send. |
705 the single quotes as we use them to escape the whole command. | |
706 timeout_time: Number of seconds to wait for command to respond before | 705 timeout_time: Number of seconds to wait for command to respond before |
707 retrying, used by AdbInterface.SendShellCommand. | 706 retrying, used by AdbInterface.SendShellCommand. |
708 log_result: Boolean to indicate whether we should log the result of the | 707 log_result: Boolean to indicate whether we should log the result of the |
709 shell command. | 708 shell command. |
710 | 709 |
711 Returns: | 710 Returns: |
712 list containing the lines of output received from running the command | 711 list containing the lines of output received from running the command |
713 """ | 712 """ |
714 self._LogShell(command) | 713 self._LogShell(command) |
715 if "'" in command: | 714 if "'" in command: |
(...skipping 1236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1952 """ | 1951 """ |
1953 def __init__(self, output): | 1952 def __init__(self, output): |
1954 self._output = output | 1953 self._output = output |
1955 | 1954 |
1956 def write(self, data): | 1955 def write(self, data): |
1957 data = data.replace('\r\r\n', '\n') | 1956 data = data.replace('\r\r\n', '\n') |
1958 self._output.write(data) | 1957 self._output.write(data) |
1959 | 1958 |
1960 def flush(self): | 1959 def flush(self): |
1961 self._output.flush() | 1960 self._output.flush() |
OLD | NEW |