| OLD | NEW |
| 1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 2013 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 """This module wraps Android's adb tool. | 5 """This module wraps Android's adb tool. |
| 6 | 6 |
| 7 This is a thin wrapper around the adb interface. Any additional complexity | 7 This is a thin wrapper around the adb interface. Any additional complexity |
| 8 should be delegated to a higher level (ex. DeviceUtils). | 8 should be delegated to a higher level (ex. DeviceUtils). |
| 9 """ | 9 """ |
| 10 | 10 |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 class PersistentShell(object): | 128 class PersistentShell(object): |
| 129 '''Class to use persistent shell for ADB. | 129 '''Class to use persistent shell for ADB. |
| 130 | 130 |
| 131 This class allows a persistent ADB shell to be created, where multiple | 131 This class allows a persistent ADB shell to be created, where multiple |
| 132 commands can be passed into it. This avoids the overhead of starting | 132 commands can be passed into it. This avoids the overhead of starting |
| 133 up a new ADB shell for each command. | 133 up a new ADB shell for each command. |
| 134 | 134 |
| 135 Example of use: | 135 Example of use: |
| 136 with PersistentShell('123456789') as pshell: | 136 with PersistentShell('123456789') as pshell: |
| 137 pshell.RunCommand('which ls') | 137 pshell.RunCommand('which ls') |
| 138 pshell.RunCommandAndClose('echo TEST') | 138 pshell.RunCommand('echo TEST', close=True) |
| 139 ''' | 139 ''' |
| 140 def __init__(self, serial): | 140 def __init__(self, serial): |
| 141 """Initialization function: | 141 """Initialization function: |
| 142 | 142 |
| 143 Args: | 143 Args: |
| 144 serial: Serial number of device. | 144 serial: Serial number of device. |
| 145 """ | 145 """ |
| 146 self._cmd = [AdbWrapper.GetAdbPath(), '-s', serial, 'shell'] | 146 self._cmd = [AdbWrapper.GetAdbPath(), '-s', serial, 'shell'] |
| 147 self._process = None | 147 self._process = None |
| 148 | 148 |
| (...skipping 759 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 908 @property | 908 @property |
| 909 def is_emulator(self): | 909 def is_emulator(self): |
| 910 return _EMULATOR_RE.match(self._device_serial) | 910 return _EMULATOR_RE.match(self._device_serial) |
| 911 | 911 |
| 912 @property | 912 @property |
| 913 def is_ready(self): | 913 def is_ready(self): |
| 914 try: | 914 try: |
| 915 return self.GetState() == _READY_STATE | 915 return self.GetState() == _READY_STATE |
| 916 except device_errors.CommandFailedError: | 916 except device_errors.CommandFailedError: |
| 917 return False | 917 return False |
| OLD | NEW |