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

Side by Side Diff: build/android/buildbot/bb_device_status_check.py

Issue 1571803002: [Android] Prepare build/android/ for catapult+devil. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@create-device-library-links
Patch Set: rebase 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 | « build/android/bb_run_sharded_steps.py ('k') | build/android/buildbot/bb_device_steps.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # 2 #
3 # Copyright 2013 The Chromium Authors. All rights reserved. 3 # Copyright 2013 The Chromium Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be 4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file. 5 # found in the LICENSE file.
6 6
7 """A class to keep track of devices across builds and report state.""" 7 """A class to keep track of devices across builds and report state."""
8 8
9 import argparse 9 import argparse
10 import json 10 import json
11 import logging 11 import logging
12 import os 12 import os
13 import psutil 13 import psutil
14 import re 14 import re
15 import signal 15 import signal
16 import sys 16 import sys
17 17
18 sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) 18 sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
19 import devil_chromium 19 import devil_chromium
20 from devil.android import battery_utils 20 from devil.android import battery_utils
21 from devil.android import device_blacklist 21 from devil.android import device_blacklist
22 from devil.android import device_errors 22 from devil.android import device_errors
23 from devil.android import device_list 23 from devil.android import device_list
24 from devil.android import device_utils 24 from devil.android import device_utils
25 from devil.android.sdk import adb_wrapper 25 from devil.android.sdk import adb_wrapper
26 from devil.constants import exit_codes
26 from devil.utils import lsusb 27 from devil.utils import lsusb
27 from devil.utils import reset_usb 28 from devil.utils import reset_usb
28 from devil.utils import run_tests_helper 29 from devil.utils import run_tests_helper
29 from pylib import constants 30 from pylib.constants import host_paths
30 31
31 _RE_DEVICE_ID = re.compile(r'Device ID = (\d+)') 32 _RE_DEVICE_ID = re.compile(r'Device ID = (\d+)')
32 33
33 34
34 def KillAllAdb(): 35 def KillAllAdb():
35 def GetAllAdb(): 36 def GetAllAdb():
36 for p in psutil.process_iter(): 37 for p in psutil.process_iter():
37 try: 38 try:
38 if 'adb' in p.name: 39 if 'adb' in p.name:
39 yield p 40 yield p
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 blacklist.Extend([device.adb.GetDeviceSerial()], 291 blacklist.Extend([device.adb.GetDeviceSerial()],
291 reason='reboot_timeout') 292 reason='reboot_timeout')
292 293
293 device_utils.DeviceUtils.parallel(devices).pMap(blacklisting_recovery) 294 device_utils.DeviceUtils.parallel(devices).pMap(blacklisting_recovery)
294 295
295 296
296 def main(): 297 def main():
297 parser = argparse.ArgumentParser() 298 parser = argparse.ArgumentParser()
298 parser.add_argument('--out-dir', 299 parser.add_argument('--out-dir',
299 help='Directory where the device path is stored', 300 help='Directory where the device path is stored',
300 default=os.path.join(constants.DIR_SOURCE_ROOT, 'out')) 301 default=os.path.join(host_paths.DIR_SOURCE_ROOT, 'out'))
301 parser.add_argument('--restart-usb', action='store_true', 302 parser.add_argument('--restart-usb', action='store_true',
302 help='DEPRECATED. ' 303 help='DEPRECATED. '
303 'This script now always tries to reset USB.') 304 'This script now always tries to reset USB.')
304 parser.add_argument('--json-output', 305 parser.add_argument('--json-output',
305 help='Output JSON information into a specified file.') 306 help='Output JSON information into a specified file.')
306 parser.add_argument('--blacklist-file', help='Device blacklist JSON file.') 307 parser.add_argument('--blacklist-file', help='Device blacklist JSON file.')
307 parser.add_argument('-v', '--verbose', action='count', default=1, 308 parser.add_argument('-v', '--verbose', action='count', default=1,
308 help='Log more information.') 309 help='Log more information.')
309 310
310 args = parser.parse_args() 311 args = parser.parse_args()
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 # Dump the device statuses to JSON. 384 # Dump the device statuses to JSON.
384 if args.json_output: 385 if args.json_output:
385 with open(args.json_output, 'wb') as f: 386 with open(args.json_output, 'wb') as f:
386 f.write(json.dumps(statuses, indent=4)) 387 f.write(json.dumps(statuses, indent=4))
387 388
388 live_devices = [status['serial'] for status in statuses 389 live_devices = [status['serial'] for status in statuses
389 if (status['adb_status'] == 'device' 390 if (status['adb_status'] == 'device'
390 and not _IsBlacklisted(status['serial'], blacklist))] 391 and not _IsBlacklisted(status['serial'], blacklist))]
391 392
392 # If all devices failed, or if there are no devices, it's an infra error. 393 # If all devices failed, or if there are no devices, it's an infra error.
393 return 0 if live_devices else constants.INFRA_EXIT_CODE 394 return 0 if live_devices else exit_codes.INFRA
394 395
395 396
396 if __name__ == '__main__': 397 if __name__ == '__main__':
397 sys.exit(main()) 398 sys.exit(main())
OLDNEW
« no previous file with comments | « build/android/bb_run_sharded_steps.py ('k') | build/android/buildbot/bb_device_steps.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698