| OLD | NEW |
| 1 # Copyright 2015 Google Inc. All rights reserved. | 1 # Copyright 2015 Google Inc. All rights reserved. |
| 2 # | 2 # |
| 3 # Licensed under the Apache License, Version 2.0 (the "License"); | 3 # Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 # you may not use this file except in compliance with the License. | 4 # you may not use this file except in compliance with the License. |
| 5 # You may obtain a copy of the License at | 5 # You may obtain a copy of the License at |
| 6 # | 6 # |
| 7 # http://www.apache.org/licenses/LICENSE-2.0 | 7 # http://www.apache.org/licenses/LICENSE-2.0 |
| 8 # | 8 # |
| 9 # Unless required by applicable law or agreed to in writing, software | 9 # Unless required by applicable law or agreed to in writing, software |
| 10 # distributed under the License is distributed on an "AS IS" BASIS, | 10 # distributed under the License is distributed on an "AS IS" BASIS, |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 time.sleep(0.001) | 70 time.sleep(0.001) |
| 71 | 71 |
| 72 try: | 72 try: |
| 73 processes = subprocess.check_output(['ps', 'aux']).splitlines() | 73 processes = subprocess.check_output(['ps', 'aux']).splitlines() |
| 74 except subprocess.CalledProcessError: | 74 except subprocess.CalledProcessError: |
| 75 _LOG.error('KillADB(): unable to scan process list.') | 75 _LOG.error('KillADB(): unable to scan process list.') |
| 76 processes = [] | 76 processes = [] |
| 77 | 77 |
| 78 culprits = '\n'.join(p for p in processes if 'adb' in p) | 78 culprits = '\n'.join(p for p in processes if 'adb' in p) |
| 79 _LOG.error( | 79 _LOG.error( |
| 80 'KillADB() failed after %d attempts. Potential culprits: %s' % culprits) | 80 'KillADB() failed after %d attempts. Potential culprits: %s', |
| 81 attempts, culprits) |
| 81 | 82 |
| 82 | 83 |
| 83 class AdbCommandsSafe(object): | 84 class AdbCommandsSafe(object): |
| 84 """Wraps an AdbCommands to make it exception safe. | 85 """Wraps an AdbCommands to make it exception safe. |
| 85 | 86 |
| 86 The fact that exceptions can be thrown any time makes the client code really | 87 The fact that exceptions can be thrown any time makes the client code really |
| 87 hard to write safely. Convert USBError* to None return value. | 88 hard to write safely. Convert USBError* to None return value. |
| 88 | 89 |
| 89 Only contains the low level commands. High level operations are built upon the | 90 Only contains the low level commands. High level operations are built upon the |
| 90 low level functionality provided by this class. | 91 low level functionality provided by this class. |
| (...skipping 813 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 904 self.Close() | 905 self.Close() |
| 905 if not self._WaitUntilFound(use_serial=use_serial, timeout=timeout): | 906 if not self._WaitUntilFound(use_serial=use_serial, timeout=timeout): |
| 906 return False | 907 return False |
| 907 if not self._OpenHandle(): | 908 if not self._OpenHandle(): |
| 908 return False | 909 return False |
| 909 return self._Connect(use_serial=use_serial) | 910 return self._Connect(use_serial=use_serial) |
| 910 | 911 |
| 911 def __repr__(self): | 912 def __repr__(self): |
| 912 return '<Device %s %s>' % ( | 913 return '<Device %s %s>' % ( |
| 913 self.port_path, self.serial if self.is_valid else '(broken)') | 914 self.port_path, self.serial if self.is_valid else '(broken)') |
| OLD | NEW |