| 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 810 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 821 self._handle, banner=self._banner, rsa_keys=self._rsa_keys, | 821 self._handle, banner=self._banner, rsa_keys=self._rsa_keys, |
| 822 auth_timeout_ms=self._auth_timeout_ms) | 822 auth_timeout_ms=self._auth_timeout_ms) |
| 823 self._failure = None if self._adb_cmd else 'unknown' | 823 self._failure = None if self._adb_cmd else 'unknown' |
| 824 break | 824 break |
| 825 except usb_exceptions.DeviceAuthError as e: | 825 except usb_exceptions.DeviceAuthError as e: |
| 826 self._failure = 'unauthorized' | 826 self._failure = 'unauthorized' |
| 827 _LOG.warning('AUTH FAILURE: %s: %s', self.port_path, e) | 827 _LOG.warning('AUTH FAILURE: %s: %s', self.port_path, e) |
| 828 except usb_exceptions.LibusbWrappingError as e: | 828 except usb_exceptions.LibusbWrappingError as e: |
| 829 self._failure = 'usb_failure' | 829 self._failure = 'usb_failure' |
| 830 _LOG.warning('I/O FAILURE: %s: %s', self.port_path, e) | 830 _LOG.warning('I/O FAILURE: %s: %s', self.port_path, e) |
| 831 self._handle.Reset() | 831 # TODO(crbug.com/642440): Reset the handle here if fleet health |
| 832 # regresses and host kernel panics don't subside. |
| 832 except adb_protocol.InvalidResponseError as e: | 833 except adb_protocol.InvalidResponseError as e: |
| 833 self._failure = 'protocol_fault' | 834 self._failure = 'protocol_fault' |
| 834 _LOG.warning('SYNC FAILURE: %s: %s', self.port_path, e) | 835 _LOG.warning('SYNC FAILURE: %s: %s', self.port_path, e) |
| 835 finally: | 836 finally: |
| 836 # Do not leak the USB handle when we can't talk to the device. | 837 # Do not leak the USB handle when we can't talk to the device. |
| 837 if not self._adb_cmd: | 838 if not self._adb_cmd: |
| 838 self.Close() | 839 self.Close() |
| 839 | 840 |
| 840 if not self._adb_cmd and self._handle: | 841 if not self._adb_cmd and self._handle: |
| 841 _LOG.error('Unexpected close') | 842 _LOG.error('Unexpected close') |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 882 self.Close() | 883 self.Close() |
| 883 if not self._WaitUntilFound(use_serial=use_serial, timeout=timeout): | 884 if not self._WaitUntilFound(use_serial=use_serial, timeout=timeout): |
| 884 return False | 885 return False |
| 885 if not self._OpenHandle(): | 886 if not self._OpenHandle(): |
| 886 return False | 887 return False |
| 887 return self._Connect(use_serial=use_serial) | 888 return self._Connect(use_serial=use_serial) |
| 888 | 889 |
| 889 def __repr__(self): | 890 def __repr__(self): |
| 890 return '<Device %s %s>' % ( | 891 return '<Device %s %s>' % ( |
| 891 self.port_path, self.serial if self.is_valid else '(broken)') | 892 self.port_path, self.serial if self.is_valid else '(broken)') |
| OLD | NEW |