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 755 matching lines...) Loading... |
766 # If this succeeds, this initializes self._handle._handle, which is a | 766 # If this succeeds, this initializes self._handle._handle, which is a |
767 # usb1.USBDeviceHandle. | 767 # usb1.USBDeviceHandle. |
768 self._handle.Open() | 768 self._handle.Open() |
769 return True | 769 return True |
770 except common.usb1.USBErrorNoDevice as e: | 770 except common.usb1.USBErrorNoDevice as e: |
771 _LOG.warning( | 771 _LOG.warning( |
772 '%s._OpenHandle(): USBErrorNoDevice: %s', self.port_path, e) | 772 '%s._OpenHandle(): USBErrorNoDevice: %s', self.port_path, e) |
773 # Do not kill adb, it just means the USB host is likely resetting and | 773 # Do not kill adb, it just means the USB host is likely resetting and |
774 # the device is temporarily unavailable. We can't use | 774 # the device is temporarily unavailable. We can't use |
775 # handle.serial_number since this communicates with the device. | 775 # handle.serial_number since this communicates with the device. |
| 776 # Might take a while for the device to come back. Exit early. |
| 777 break |
776 except common.usb1.USBErrorNotFound as e: | 778 except common.usb1.USBErrorNotFound as e: |
777 _LOG.warning( | 779 _LOG.warning( |
778 '%s._OpenHandle(): USBErrorNotFound: %s', self.port_path, e) | 780 '%s._OpenHandle(): USBErrorNotFound: %s', self.port_path, e) |
779 # Do not kill adb, it just means the USB host is likely resetting (?) | 781 # Do not kill adb, it just means the USB host is likely resetting (?) |
780 # and the device is temporarily unavailable. We can't use | 782 # and the device is temporarily unavailable. We can't use |
781 # handle.serial_number since this communicates with the device. | 783 # handle.serial_number since this communicates with the device. |
| 784 # Might take a while for the device to come back. Exit early. |
| 785 break |
782 except common.usb1.USBErrorBusy as e: | 786 except common.usb1.USBErrorBusy as e: |
783 _LOG.warning('%s._OpenHandle(): USBErrorBusy: %s', self.port_path, e) | 787 _LOG.warning('%s._OpenHandle(): USBErrorBusy: %s', self.port_path, e) |
784 KillADB() | 788 KillADB() |
785 except common.usb1.USBErrorAccess as e: | 789 except common.usb1.USBErrorAccess as e: |
786 # Do not try to use serial_number, since we can't even access the | 790 # Do not try to use serial_number, since we can't even access the |
787 # port. | 791 # port. |
788 _LOG.error( | 792 _LOG.error( |
789 '%s._OpenHandle(): No access, maybe change udev rule or add ' | 793 '%s._OpenHandle(): No access, maybe change udev rule or add ' |
790 'yourself to plugdev: %s', self.port_path, e) | 794 'yourself to plugdev: %s', self.port_path, e) |
791 # Not worth retrying, exit early. | 795 # Not worth retrying, exit early. |
(...skipping 108 matching lines...) Loading... |
900 self.Close() | 904 self.Close() |
901 if not self._WaitUntilFound(use_serial=use_serial, timeout=timeout): | 905 if not self._WaitUntilFound(use_serial=use_serial, timeout=timeout): |
902 return False | 906 return False |
903 if not self._OpenHandle(): | 907 if not self._OpenHandle(): |
904 return False | 908 return False |
905 return self._Connect(use_serial=use_serial) | 909 return self._Connect(use_serial=use_serial) |
906 | 910 |
907 def __repr__(self): | 911 def __repr__(self): |
908 return '<Device %s %s>' % ( | 912 return '<Device %s %s>' % ( |
909 self.port_path, self.serial if self.is_valid else '(broken)') | 913 self.port_path, self.serial if self.is_valid else '(broken)') |
OLD | NEW |