Chromium Code Reviews| Index: appengine/third_party/python-adb/adb/adb_commands_safe.py |
| diff --git a/appengine/third_party/python-adb/adb/adb_commands_safe.py b/appengine/third_party/python-adb/adb/adb_commands_safe.py |
| index 4dd22ee44c76425684529b7d12403475db0b6b56..5b4a54ea05b578261bf4f7fc816b060b4949addf 100644 |
| --- a/appengine/third_party/python-adb/adb/adb_commands_safe.py |
| +++ b/appengine/third_party/python-adb/adb/adb_commands_safe.py |
| @@ -345,7 +345,7 @@ class AdbCommandsSafe(object): |
| return True |
| time.sleep(0.1) |
| _LOG.error( |
| - '%s.Reboot(): Failed to id after %d tries', self.port_path, i+1) |
| + '%s.Reboot(): Failed to reboot after %d tries', self.port_path, i+1) |
| return False |
| def Remount(self): |
| @@ -493,6 +493,10 @@ class AdbCommandsSafe(object): |
| """Reboots the phone.""" |
| i = 0 |
| for i in self._Loop(): |
| + # TODO(maruel): It looks like it's possible that the device restart so |
| + # fast that it throws an exception at the USB level. In that case there's |
| + # no way to know if the command worked too fast or something went wrong |
| + # and the command didn't go through. |
| try: |
| out = self._adb_cmd.Reboot() |
| except self._ERRORS as e: |
| @@ -584,8 +588,9 @@ class AdbCommandsSafe(object): |
| previous_port_path, use_serial, self._serial, |
| self.port_path if self._handle else 'None') |
| except (common.usb1.USBError, usb_exceptions.DeviceNotFoundError) as e: |
| - _LOG.info( |
| + _LOG.debug( |
| '%s._Find(%s) %s : %s', self.port_path, use_serial, self._serial, e) |
| + return bool(self._handle) |
| def _WaitUntilFound(self, use_serial): |
| """Loops until the device is found on the USB bus. |
| @@ -599,13 +604,8 @@ class AdbCommandsSafe(object): |
| _LOG.debug('%s._WaitUntilFound(%s)', self.port_path, use_serial) |
| i = 0 |
| for i in self._Loop(): |
| - try: |
| - self._Find(use_serial=use_serial) |
| + if self._Find(use_serial=use_serial): |
| return |
| - except usb_exceptions.DeviceNotFoundError as e: |
| - _LOG.info( |
| - '%s._WaitUntilFound(): Retrying _Find() due to %s', |
| - self.port_path, e) |
| _LOG.warning( |
| '%s._WaitUntilFound() gave up after %d tries', self.port_path, i+1) |
| @@ -635,6 +635,7 @@ class AdbCommandsSafe(object): |
| # port. |
| _LOG.warning( |
| '%s._OpenHandle(): Try rebooting the host: %s', self.port_path, e) |
| + self.Close() |
|
ghost stip (do not use)
2015/11/03 18:50:46
*sigh* context manager, man
M-A Ruel
2015/11/04 18:39:10
It's in a loop, I changed the break at line 623 to
|
| break |
| else: |
| _LOG.error( |