| OLD | NEW |
| 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 argparse | |
| 6 import fcntl | |
| 7 import logging | 5 import logging |
| 8 import re | 6 import re |
| 9 import sys | |
| 10 | 7 |
| 11 from pylib import cmd_helper | 8 from pylib import cmd_helper |
| 12 from pylib.device import adb_wrapper | |
| 13 from pylib.device import device_errors | |
| 14 from pylib.utils import run_tests_helper | |
| 15 | 9 |
| 16 _INDENTATION_RE = re.compile(r'^( *)') | 10 _INDENTATION_RE = re.compile(r'^( *)') |
| 17 _LSUSB_BUS_DEVICE_RE = re.compile(r'^Bus (\d{3}) Device (\d{3}):') | 11 _LSUSB_BUS_DEVICE_RE = re.compile(r'^Bus (\d{3}) Device (\d{3}):') |
| 18 _LSUSB_ENTRY_RE = re.compile(r'^ *([^ ]+) +([^ ]+) *([^ ].*)?$') | 12 _LSUSB_ENTRY_RE = re.compile(r'^ *([^ ]+) +([^ ]+) *([^ ].*)?$') |
| 19 _LSUSB_GROUP_RE = re.compile(r'^ *([^ ]+.*):$') | 13 _LSUSB_GROUP_RE = re.compile(r'^ *([^ ]+.*):$') |
| 20 | 14 |
| 21 _USBDEVFS_RESET = ord('U') << 8 | 20 | 15 _USBDEVFS_RESET = ord('U') << 8 | 20 |
| 22 | 16 |
| 23 | 17 |
| 24 def lsusb(): | 18 def lsusb(): |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 | 78 |
| 85 | 79 |
| 86 def get_lsusb_serial(device): | 80 def get_lsusb_serial(device): |
| 87 return device.get('Device Descriptor', {}).get('iSerial', {}).get('_desc') | 81 return device.get('Device Descriptor', {}).get('iSerial', {}).get('_desc') |
| 88 | 82 |
| 89 | 83 |
| 90 def get_android_devices(): | 84 def get_android_devices(): |
| 91 return [serial for serial in (get_lsusb_serial(d) for d in lsusb()) | 85 return [serial for serial in (get_lsusb_serial(d) for d in lsusb()) |
| 92 if serial] | 86 if serial] |
| 93 | 87 |
| OLD | NEW |