Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6)

Side by Side Diff: build/android/devil/utils/lsusb.py

Issue 1635763002: [Android] Do not fail devices status check if lsusb -v times out (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2015 The Chromium Authors. All rights reserved. 1 # Copyright 2015 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import logging 5 import logging
6 import re 6 import re
7 7
8 from devil.utils import cmd_helper 8 from devil.utils import cmd_helper
9 9
10 _COULDNT_OPEN_ERROR_RE = re.compile(r'Couldn\'t open device.*') 10 _COULDNT_OPEN_ERROR_RE = re.compile(r'Couldn\'t open device.*')
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 def lsusb(): 80 def lsusb():
81 """Call lsusb and return the parsed output.""" 81 """Call lsusb and return the parsed output."""
82 _, lsusb_list_output = cmd_helper.GetCmdStatusAndOutputWithTimeout( 82 _, lsusb_list_output = cmd_helper.GetCmdStatusAndOutputWithTimeout(
83 ['lsusb'], timeout=2) 83 ['lsusb'], timeout=2)
84 devices = [] 84 devices = []
85 for line in lsusb_list_output.splitlines(): 85 for line in lsusb_list_output.splitlines():
86 m = _LSUSB_BUS_DEVICE_RE.match(line) 86 m = _LSUSB_BUS_DEVICE_RE.match(line)
87 if m: 87 if m:
88 bus_num = m.group(1) 88 bus_num = m.group(1)
89 dev_num = m.group(2) 89 dev_num = m.group(2)
90 devices.append(_lsusbv_on_device(bus_num, dev_num)) 90 try:
91 devices.append(_lsusbv_on_device(bus_num, dev_num))
92 except cmd_helper.TimeoutError:
93 # Will be blacklisted if it is in expected device file, but times out.
94 logging.info('lsusb -v %s:%s timed out.', bus_num, dev_num)
95
91 return devices 96 return devices
92 97
93 def get_lsusb_serial(device): 98 def get_lsusb_serial(device):
94 try: 99 try:
95 return device['Device Descriptor']['iSerial']['_desc'] 100 return device['Device Descriptor']['iSerial']['_desc']
96 except KeyError: 101 except KeyError:
97 return None 102 return None
98 103
99 def get_android_devices(): 104 def get_android_devices():
100 return [serial for serial in (get_lsusb_serial(d) for d in lsusb()) 105 return [serial for serial in (get_lsusb_serial(d) for d in lsusb())
101 if serial] 106 if serial]
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698