Chromium Code Reviews| Index: build/android/buildbot/bb_device_status_check.py |
| diff --git a/build/android/buildbot/bb_device_status_check.py b/build/android/buildbot/bb_device_status_check.py |
| index cba8132003959872a82ad8c425fa6522bd1c8320..e4191edea1f8800da0aeaf3c81acf08624fd6ae0 100755 |
| --- a/build/android/buildbot/bb_device_status_check.py |
| +++ b/build/android/buildbot/bb_device_status_check.py |
| @@ -225,7 +225,7 @@ def RestartUsb(): |
| if not os.path.isfile('/usr/bin/restart_usb'): |
| print ('ERROR: Could not restart usb. /usr/bin/restart_usb not installed ' |
| 'on host (see BUG=305769).') |
| - return 1 |
| + return False |
| lsusb_proc = bb_utils.SpawnCmd(['lsusb'], stdout=subprocess.PIPE) |
| lsusb_output, _ = lsusb_proc.communicate() |
| @@ -236,7 +236,7 @@ def RestartUsb(): |
| usb_devices = [re.findall('Bus (\d\d\d) Device (\d\d\d)', lsusb_line)[0] |
| for lsusb_line in lsusb_output.strip().split('\n')] |
| - failed_restart = False |
| + restarted = True |
|
navabi
2014/01/09 23:31:39
This boolean indicates if all usb devices were res
bulach
2014/01/10 09:08:05
good point! done.
|
| # Walk USB devices from leaves up (i.e reverse sorted) restarting the |
| # connection. If a parent node (e.g. usb hub) is restarted before the |
| # devices connected to it, the (bus, dev) for the hub can change, making the |
| @@ -247,14 +247,11 @@ def RestartUsb(): |
| return_code = bb_utils.RunCmd(['/usr/bin/restart_usb', bus, dev]) |
| if return_code: |
| print 'Error restarting USB device /dev/bus/usb/%s/%s' % (bus, dev) |
| - failed_restart = True |
| + restarted = False |
| else: |
| print 'Restarted USB device /dev/bus/usb/%s/%s' % (bus, dev) |
| - if failed_restart: |
| - return 1 |
| - |
| - return 0 |
| + return restarted |
| def KillAllAdb(): |
| @@ -299,18 +296,24 @@ def main(): |
| if options.restart_usb: |
| expected_devices = GetLastDevices(os.path.abspath(options.out_dir)) |
| devices = android_commands.GetAttachedDevices() |
| - # Only restart usb if devices are missing |
| + # Only restart usb if devices are missing. |
| if set(expected_devices) != set(devices): |
| KillAllAdb() |
| retries = 5 |
| - if RestartUsb(): |
| + usb_restarted = True |
| + if not RestartUsb(): |
| + usb_restarted = False |
| bb_annotations.PrintWarning() |
| - print "USB reset stage failed, continuing anyway." |
| - retries = 0 |
| + print 'USB reset stage failed, wait for any device to come back.' |
| while retries: |
| time.sleep(1) |
| devices = android_commands.GetAttachedDevices() |
| if set(expected_devices) == set(devices): |
| + # All devices are online, keep going. |
| + break |
| + if not usb_restarted and devices: |
| + # The USB wasn't restarted, but there's at least one device online. |
| + # No point in trying to wait for all devices. |
| break |
| retries -= 1 |