| 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 737 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 748 # If this succeeds, this initializes self._handle._handle, which is a | 748 # If this succeeds, this initializes self._handle._handle, which is a |
| 749 # usb1.USBDeviceHandle. | 749 # usb1.USBDeviceHandle. |
| 750 self._handle.Open() | 750 self._handle.Open() |
| 751 return True | 751 return True |
| 752 except common.usb1.USBErrorNoDevice as e: | 752 except common.usb1.USBErrorNoDevice as e: |
| 753 _LOG.warning( | 753 _LOG.warning( |
| 754 '%s._OpenHandle(): USBErrorNoDevice: %s', self.port_path, e) | 754 '%s._OpenHandle(): USBErrorNoDevice: %s', self.port_path, e) |
| 755 # Do not kill adb, it just means the USB host is likely resetting and | 755 # Do not kill adb, it just means the USB host is likely resetting and |
| 756 # the device is temporarily unavailable. We can't use | 756 # the device is temporarily unavailable. We can't use |
| 757 # handle.serial_number since this communicates with the device. | 757 # handle.serial_number since this communicates with the device. |
| 758 except common.usb1.USBErrorNotFound as e: |
| 759 _LOG.warning( |
| 760 '%s._OpenHandle(): USBErrorNotFound: %s', self.port_path, e) |
| 761 # Do not kill adb, it just means the USB host is likely resetting (?) |
| 762 # and the device is temporarily unavailable. We can't use |
| 763 # handle.serial_number since this communicates with the device. |
| 758 except common.usb1.USBErrorBusy as e: | 764 except common.usb1.USBErrorBusy as e: |
| 759 _LOG.warning('%s._OpenHandle(): USBErrorBusy: %s', self.port_path, e) | 765 _LOG.warning('%s._OpenHandle(): USBErrorBusy: %s', self.port_path, e) |
| 760 KillADB() | 766 KillADB() |
| 761 except common.usb1.USBErrorAccess as e: | 767 except common.usb1.USBErrorAccess as e: |
| 762 # Do not try to use serial_number, since we can't even access the | 768 # Do not try to use serial_number, since we can't even access the |
| 763 # port. | 769 # port. |
| 764 _LOG.error( | 770 _LOG.error( |
| 765 '%s._OpenHandle(): No access, maybe change udev rule or add ' | 771 '%s._OpenHandle(): No access, maybe change udev rule or add ' |
| 766 'yourself to plugdev: %s', self.port_path, e) | 772 'yourself to plugdev: %s', self.port_path, e) |
| 767 # Not worth retrying, exit early. | 773 # Not worth retrying, exit early. |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 873 self.Close() | 879 self.Close() |
| 874 if not self._WaitUntilFound(use_serial=use_serial, timeout=timeout): | 880 if not self._WaitUntilFound(use_serial=use_serial, timeout=timeout): |
| 875 return False | 881 return False |
| 876 if not self._OpenHandle(): | 882 if not self._OpenHandle(): |
| 877 return False | 883 return False |
| 878 return self._Connect(use_serial=use_serial) | 884 return self._Connect(use_serial=use_serial) |
| 879 | 885 |
| 880 def __repr__(self): | 886 def __repr__(self): |
| 881 return '<Device %s %s>' % ( | 887 return '<Device %s %s>' % ( |
| 882 self.port_path, self.serial if self.is_valid else '(broken)') | 888 self.port_path, self.serial if self.is_valid else '(broken)') |
| OLD | NEW |