| 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 464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 475 """ | 475 """ |
| 476 lines = self.RunShellCommand( | 476 lines = self.RunShellCommand( |
| 477 command + '; echo %$?', timeout_time, log_result) | 477 command + '; echo %$?', timeout_time, log_result) |
| 478 last_line = lines[-1] | 478 last_line = lines[-1] |
| 479 status_pos = last_line.rfind('%') | 479 status_pos = last_line.rfind('%') |
| 480 assert status_pos >= 0 | 480 assert status_pos >= 0 |
| 481 status = int(last_line[status_pos + 1:]) | 481 status = int(last_line[status_pos + 1:]) |
| 482 if status_pos == 0: | 482 if status_pos == 0: |
| 483 lines = lines[:-1] | 483 lines = lines[:-1] |
| 484 else: | 484 else: |
| 485 lines = lines[:-1] + last_line[:status_pos] | 485 lines = lines[:-1] + [last_line[:status_pos]] |
| 486 return (status, lines) | 486 return (status, lines) |
| 487 | 487 |
| 488 def KillAll(self, process): | 488 def KillAll(self, process): |
| 489 """Android version of killall, connected via adb. | 489 """Android version of killall, connected via adb. |
| 490 | 490 |
| 491 Args: | 491 Args: |
| 492 process: name of the process to kill off | 492 process: name of the process to kill off |
| 493 | 493 |
| 494 Returns: | 494 Returns: |
| 495 the number of processes killed | 495 the number of processes killed |
| (...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1110 """ | 1110 """ |
| 1111 def __init__(self, output): | 1111 def __init__(self, output): |
| 1112 self._output = output | 1112 self._output = output |
| 1113 | 1113 |
| 1114 def write(self, data): | 1114 def write(self, data): |
| 1115 data = data.replace('\r\r\n', '\n') | 1115 data = data.replace('\r\r\n', '\n') |
| 1116 self._output.write(data) | 1116 self._output.write(data) |
| 1117 | 1117 |
| 1118 def flush(self): | 1118 def flush(self): |
| 1119 self._output.flush() | 1119 self._output.flush() |
| OLD | NEW |